From 1b1d7941ecb81de969c82acd8c41ba63b7a58e70 Mon Sep 17 00:00:00 2001 From: Maik Fischer Date: Mon, 21 Nov 2011 21:04:00 +0100 Subject: [PATCH] testcases: correctly enable lexical pragmata eval 'package foo; use strict;' enables strict within eval, it does not leak into the surrounding scope. Also fix various warnings/compile errors found due to now enabled strict and warnings. --- testcases/lib/i3test.pm | 6 +++--- testcases/t/101-focus.t | 2 +- testcases/t/102-dock.t | 8 ++++---- testcases/t/103-move.t | 2 +- testcases/t/105-stacking.t | 2 +- testcases/t/111-goto.t | 2 +- testcases/t/113-urgent.t | 6 +++--- testcases/t/117-workspace.t | 2 +- testcases/t/128-open-order.t | 2 +- testcases/t/130-close-empty-split.t | 8 ++++---- testcases/t/135-floating-focus.t | 2 +- testcases/t/138-floating-attach.t | 2 +- testcases/t/146-floating-reinsert.t | 2 +- testcases/t/157-regress-fullscreen-level-up.t | 4 ++-- testcases/t/164-kill-win-vs-client.t | 4 ++-- testcases/t/165-for_window.t | 2 +- testcases/t/166-assign.t | 18 +++++++++--------- testcases/t/167-workspace_layout.t | 5 +++-- testcases/t/172-start-on-named-ws.t | 4 ++-- 19 files changed, 42 insertions(+), 41 deletions(-) diff --git a/testcases/lib/i3test.pm b/testcases/lib/i3test.pm index d1e0ed7d..ad598b84 100644 --- a/testcases/lib/i3test.pm +++ b/testcases/lib/i3test.pm @@ -66,11 +66,11 @@ use Data::Dumper; use AnyEvent::I3; use Time::HiRes qw(sleep); use Test::Deep qw(eq_deeply cmp_deeply cmp_set cmp_bag cmp_methods useclass noclass set bag subbagof superbagof subsetof supersetof superhashof subhashof bool str arraylength Isa ignore methods regexprefonly regexpmatches num regexponly scalref reftype hashkeysonly blessed array re hash regexpref hash_each shallow array_each code arrayelementsonly arraylengthonly scalarrefonly listmethods any hashkeys isa); -use v5.10; -use strict; -use warnings; __ $tester->bail_out("$@") if $@; + feature->import(":5.10"); + strict->import; + warnings->import; @_ = ($class); goto \&Exporter::import; diff --git a/testcases/t/101-focus.t b/testcases/t/101-focus.t index 5ded494f..51119007 100644 --- a/testcases/t/101-focus.t +++ b/testcases/t/101-focus.t @@ -31,7 +31,7 @@ sub focus_after { return $x->input_focus; } -$focus = $x->input_focus; +my $focus = $x->input_focus; is($focus, $bottom->id, "Latest window focused"); $focus = focus_after('focus up'); diff --git a/testcases/t/102-dock.t b/testcases/t/102-dock.t index cad54c26..092cf3d2 100644 --- a/testcases/t/102-dock.t +++ b/testcases/t/102-dock.t @@ -88,7 +88,7 @@ $window = open_window($x, { window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), }); -my $rect = $window->rect; +$rect = $window->rect; is($rect->width, $primary->rect->width, 'dock client is as wide as the screen'); is($rect->height, 30, 'height is unchanged'); @@ -153,8 +153,8 @@ $window = open_window($x, { $window->_create(); # Add a _NET_WM_STRUT_PARTIAL hint -my $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL'); -my $atomtype = $x->atom(name => 'CARDINAL'); +$atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL'); +$atomtype = $x->atom(name => 'CARDINAL'); $x->change_property( PROP_MODE_REPLACE, @@ -180,7 +180,7 @@ $window->destroy; # regression test: transient dock client ##################################################################### -$fwindow = open_window($x, { +my $fwindow = open_window($x, { dont_map => 1, background_color => '#FF0000', window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), diff --git a/testcases/t/103-move.t b/testcases/t/103-move.t index 6e35ebe4..040faf20 100644 --- a/testcases/t/103-move.t +++ b/testcases/t/103-move.t @@ -48,7 +48,7 @@ sub focus_after { return $x->input_focus; } -$focus = $x->input_focus; +my $focus = $x->input_focus; is($focus, $bottom->id, "Latest window focused"); $focus = focus_after("ml"); diff --git a/testcases/t/105-stacking.t b/testcases/t/105-stacking.t index cc285f32..ec7b8df8 100644 --- a/testcases/t/105-stacking.t +++ b/testcases/t/105-stacking.t @@ -46,7 +46,7 @@ sub focus_after { return $x->input_focus; } -$focus = $x->input_focus; +my $focus = $x->input_focus; is($focus, $bottom->id, "Latest window focused"); $focus = focus_after("s"); diff --git a/testcases/t/111-goto.t b/testcases/t/111-goto.t index 903fa0c4..76baec0e 100644 --- a/testcases/t/111-goto.t +++ b/testcases/t/111-goto.t @@ -30,7 +30,7 @@ sub focus_after { return $x->input_focus; } -$focus = $x->input_focus; +my $focus = $x->input_focus; is($focus, $bottom->id, "Latest window focused"); $focus = focus_after('focus left'); diff --git a/testcases/t/113-urgent.t b/testcases/t/113-urgent.t index 7954408f..cb547667 100644 --- a/testcases/t/113-urgent.t +++ b/testcases/t/113-urgent.t @@ -33,10 +33,10 @@ is(@urgent, 0, 'no window got the urgent flag'); $top->add_hint('urgency'); sync_with_i3($x); -@content = @{get_ws_content($tmp)}; +my @content = @{get_ws_content($tmp)}; @urgent = grep { $_->{urgent} } @content; -$top_info = first { $_->{window} == $top->id } @content; -$bottom_info = first { $_->{window} == $bottom->id } @content; +my $top_info = first { $_->{window} == $top->id } @content; +my $bottom_info = first { $_->{window} == $bottom->id } @content; ok($top_info->{urgent}, 'top window is marked urgent'); ok(!$bottom_info->{urgent}, 'bottom window is not marked urgent'); diff --git a/testcases/t/117-workspace.t b/testcases/t/117-workspace.t index 3c3b6cc6..a88c669c 100644 --- a/testcases/t/117-workspace.t +++ b/testcases/t/117-workspace.t @@ -108,7 +108,7 @@ ok(defined($ws), "workspace 3: $tmp was created"); is($ws->{num}, 3, 'workspace number is 3'); cmd "workspace 0: $tmp"; -my $ws = get_ws("0: $tmp"); +$ws = get_ws("0: $tmp"); ok(defined($ws), "workspace 0: $tmp was created"); is($ws->{num}, 0, 'workspace number is 0'); diff --git a/testcases/t/128-open-order.t b/testcases/t/128-open-order.t index b638e708..ee58968f 100644 --- a/testcases/t/128-open-order.t +++ b/testcases/t/128-open-order.t @@ -27,7 +27,7 @@ isnt($first, $second, 'different container focused'); cmd qq|[con_id="$first"] focus|; cmd 'open'; -$content = get_ws_content($tmp); +my $content = get_ws_content($tmp); ok(@{$content} == 3, 'three containers opened'); is($content->[0]->{id}, $first, 'first container unmodified'); diff --git a/testcases/t/130-close-empty-split.t b/testcases/t/130-close-empty-split.t index 57855cd5..ce9ebd7a 100644 --- a/testcases/t/130-close-empty-split.t +++ b/testcases/t/130-close-empty-split.t @@ -17,7 +17,7 @@ cmd qq|[con_id="$first"] focus|; cmd 'split v'; -($nodes, $focus) = get_ws_content($tmp); +my ($nodes, $focus) = get_ws_content($tmp); is($nodes->[0]->{focused}, 0, 'split container not focused'); @@ -27,7 +27,7 @@ cmd 'level up'; my $split = $focus->[0]; cmd 'level down'; -my $second = open_empty_con($i3); +$second = open_empty_con($i3); isnt($first, $second, 'different container focused'); @@ -62,10 +62,10 @@ is($nodes->[0]->{focused}, 0, 'split container not focused'); # focus the split container cmd 'level up'; ($nodes, $focus) = get_ws_content($tmp); -my $split = $focus->[0]; +$split = $focus->[0]; cmd 'level down'; -my $second = open_empty_con($i3); +$second = open_empty_con($i3); isnt($first, $second, 'different container focused'); diff --git a/testcases/t/135-floating-focus.t b/testcases/t/135-floating-focus.t index b43f0f7f..5e5a68f2 100644 --- a/testcases/t/135-floating-focus.t +++ b/testcases/t/135-floating-focus.t @@ -63,7 +63,7 @@ $tmp = fresh_workspace; $first = open_window($x, { background_color => '#ff0000' }); # window 5 $second = open_window($x, { background_color => '#00ff00' }); # window 6 -my $third = open_window($x, { background_color => '#0000ff' }); # window 7 +$third = open_window($x, { background_color => '#0000ff' }); # window 7 is($x->input_focus, $third->id, 'last container focused'); diff --git a/testcases/t/138-floating-attach.t b/testcases/t/138-floating-attach.t index b08190a2..ae035f61 100644 --- a/testcases/t/138-floating-attach.t +++ b/testcases/t/138-floating-attach.t @@ -54,7 +54,7 @@ is(@{$ws->{floating_nodes}}, 0, 'no floating nodes so far'); is(@{$ws->{nodes}}, 1, 'one tiling node (stacked con)'); # Create a floating window -my $window = open_floating_window($x); +$window = open_floating_window($x); ok($window->mapped, 'Window is mapped'); $ws = get_ws($tmp); diff --git a/testcases/t/146-floating-reinsert.t b/testcases/t/146-floating-reinsert.t index bc1302bb..b63e7ac9 100644 --- a/testcases/t/146-floating-reinsert.t +++ b/testcases/t/146-floating-reinsert.t @@ -37,7 +37,7 @@ is(@{$nodes->[1]->{nodes}}, 2, 'two windows in split con'); cmd 'floating toggle'; -my ($nodes, $focus) = get_ws_content($tmp); +($nodes, $focus) = get_ws_content($tmp); is(@{$nodes->[1]->{nodes}}, 3, 'three windows in split con after floating toggle'); diff --git a/testcases/t/157-regress-fullscreen-level-up.t b/testcases/t/157-regress-fullscreen-level-up.t index 7a101dbc..f067cb93 100644 --- a/testcases/t/157-regress-fullscreen-level-up.t +++ b/testcases/t/157-regress-fullscreen-level-up.t @@ -31,7 +31,7 @@ is($nodes->[0]->{fullscreen_mode}, 0, 'client not fullscreen'); cmd 'nop making fullscreen'; cmd 'fullscreen'; -my $nodes = get_ws_content $tmp; +$nodes = get_ws_content $tmp; is($nodes->[0]->{fullscreen_mode}, 1, 'client fullscreen now'); ##################################################################### @@ -40,7 +40,7 @@ is($nodes->[0]->{fullscreen_mode}, 1, 'client fullscreen now'); cmd 'level up'; cmd 'fullscreen'; -my $nodes = get_ws_content $tmp; +$nodes = get_ws_content $tmp; is($nodes->[0]->{fullscreen_mode}, 0, 'client not fullscreen any longer'); does_i3_live; diff --git a/testcases/t/164-kill-win-vs-client.t b/testcases/t/164-kill-win-vs-client.t index ef45a789..41ae6432 100644 --- a/testcases/t/164-kill-win-vs-client.t +++ b/testcases/t/164-kill-win-vs-client.t @@ -42,7 +42,7 @@ ok(@{get_ws_content($tmp)} == 1, 'one container left after killing'); # 'kill window' ############################################################## -my $tmp = two_windows; +$tmp = two_windows; cmd 'kill window'; @@ -55,7 +55,7 @@ ok(@{get_ws_content($tmp)} == 1, 'one container left after killing'); # and check if both are gone ############################################################## -my $tmp = two_windows; +$tmp = two_windows; cmd 'kill client'; diff --git a/testcases/t/165-for_window.t b/testcases/t/165-for_window.t index 6e921cef..b3fef117 100644 --- a/testcases/t/165-for_window.t +++ b/testcases/t/165-for_window.t @@ -46,7 +46,7 @@ is($content[0]->{border}, 'normal', 'normal border'); $window->unmap; wait_for_unmap $x; -my @content = @{get_ws_content($tmp)}; +@content = @{get_ws_content($tmp)}; cmp_ok(@content, '==', 0, 'no more nodes'); diag('content = '. Dumper(\@content)); diff --git a/testcases/t/166-assign.t b/testcases/t/166-assign.t index 4844f5b5..9492486c 100644 --- a/testcases/t/166-assign.t +++ b/testcases/t/166-assign.t @@ -84,7 +84,7 @@ ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); my $workspaces = get_workspace_names; ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet'); -my $window = $x->root->create_child( +$window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => [ 0, 0, 30, 30 ], background_color => '#0000ff', @@ -124,7 +124,7 @@ $tmp = fresh_workspace; ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); ok("targetws" ~~ @{get_workspace_names()}, 'targetws does not exist yet'); -my $window = $x->root->create_child( +$window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => [ 0, 0, 30, 30 ], background_color => '#0000ff', @@ -162,10 +162,10 @@ $pid = launch_with_config($config); $tmp = fresh_workspace; ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); -my $workspaces = get_workspace_names; +$workspaces = get_workspace_names; ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet'); -my $window = $x->root->create_child( +$window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => [ 0, 0, 30, 30 ], background_color => '#0000ff', @@ -203,10 +203,10 @@ $pid = launch_with_config($config); $tmp = fresh_workspace; ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); -my $workspaces = get_workspace_names; +$workspaces = get_workspace_names; ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet'); -my $window = $x->root->create_child( +$window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => [ 0, 0, 30, 30 ], background_color => '#0000ff', @@ -219,7 +219,7 @@ $window->name('special window'); $window->map; wait_for_map $x; -my $content = get_ws($tmp); +$content = get_ws($tmp); ok(@{$content->{nodes}} == 0, 'no tiling cons'); ok(@{$content->{floating_nodes}} == 1, 'one floating con'); @@ -255,7 +255,7 @@ my @docked = get_dock_clients; # syntax is(@docked, 1, 'one dock client yet'); -my $window = $x->root->create_child( +$window = $x->root->create_child( class => WINDOW_CLASS_INPUT_OUTPUT, rect => [ 0, 0, 30, 30 ], background_color => '#0000ff', @@ -269,7 +269,7 @@ $window->name('special window'); $window->map; wait_for_map $x; -my $content = get_ws($tmp); +$content = get_ws($tmp); ok(@{$content->{nodes}} == 0, 'no tiling cons'); ok(@{$content->{floating_nodes}} == 0, 'one floating con'); @docked = get_dock_clients; diff --git a/testcases/t/167-workspace_layout.t b/testcases/t/167-workspace_layout.t index e4b18adf..553717c5 100644 --- a/testcases/t/167-workspace_layout.t +++ b/testcases/t/167-workspace_layout.t @@ -33,7 +33,8 @@ my $second = open_window($x); sync_with_i3($x); is($x->input_focus, $second->id, 'second window focused'); -ok(@{get_ws_content($tmp)} == 2, 'two containers opened'); +my @content = @{get_ws_content($tmp)}; +ok(@content == 2, 'two containers opened'); isnt($content[0]->{layout}, 'stacked', 'layout not stacked'); isnt($content[1]->{layout}, 'stacked', 'layout not stacked'); @@ -62,7 +63,7 @@ $second = open_window($x); sync_with_i3($x); is($x->input_focus, $second->id, 'second window focused'); -my @content = @{get_ws_content($tmp)}; +@content = @{get_ws_content($tmp)}; ok(@content == 1, 'one con at workspace level'); is($content[0]->{layout}, 'stacked', 'layout stacked'); diff --git a/testcases/t/172-start-on-named-ws.t b/testcases/t/172-start-on-named-ws.t index 4493bf83..cdd2001d 100644 --- a/testcases/t/172-start-on-named-ws.t +++ b/testcases/t/172-start-on-named-ws.t @@ -39,7 +39,7 @@ EOT $pid = launch_with_config($config); -my @names = @{get_workspace_names()}; +@names = @{get_workspace_names()}; cmp_deeply(\@names, [ 'foobar' ], 'i3 starts on named workspace foobar'); exit_gracefully($pid); @@ -57,7 +57,7 @@ EOT $pid = launch_with_config($config); -my @names = @{get_workspace_names()}; +@names = @{get_workspace_names()}; cmp_deeply(\@names, [ 'foobar' ], 'i3 starts on named workspace foobar'); exit_gracefully($pid); -- 2.39.5