]> git.sur5r.net Git - i3/i3/blobdiff - testcases/lib/i3test.pm
i3test.pm: use strict; use warnings; and fix related bugs
[i3/i3] / testcases / lib / i3test.pm
index cf29d7b9eb797ef86e8f02182a7d9f03b8a9e357..39fd7a94e05195cd6ee985ce7e16b62e3b95cc29 100644 (file)
@@ -1,5 +1,6 @@
 package i3test;
 # vim:ts=4:sw=4:expandtab
+use strict; use warnings;
 
 use File::Temp qw(tmpnam tempfile tempdir);
 use Test::Builder;
@@ -9,11 +10,8 @@ use X11::XCB qw(:all);
 use AnyEvent::I3;
 use EV;
 use List::Util qw(first);
-use List::MoreUtils qw(lastval);
 use Time::HiRes qw(sleep);
-use Try::Tiny;
 use Cwd qw(abs_path);
-use Proc::Background;
 use SocketActivation;
 
 use v5.10;
@@ -246,7 +244,7 @@ sub get_focused {
         $lf = $focused[0];
         last unless defined($con->{focus});
         @focused = @{$con->{focus}};
-        @cons = grep { $_->{id} == $lf } (@{$con->{nodes}}, @{$con->{'floating_nodes'}});
+        my @cons = grep { $_->{id} == $lf } (@{$con->{nodes}}, @{$con->{'floating_nodes'}});
         $con = $cons[0];
     }
 
@@ -269,7 +267,8 @@ sub get_dock_clients {
             my $first = first { $_->{type} == 5 } @{$output->{nodes}};
             @docked = (@docked, @{$first->{nodes}});
         } elsif ($which eq 'bottom') {
-            my $last = lastval { $_->{type} == 5 } @{$output->{nodes}};
+            my @matching = grep { $_->{type} == 5 } @{$output->{nodes}};
+            my $last = $matching[-1];
             @docked = (@docked, @{$last->{nodes}});
         }
     }
@@ -375,7 +374,7 @@ sub exit_gracefully {
     $socketpath ||= get_socket_path();
 
     my $exited = 0;
-    try {
+    eval {
         say "Exiting i3 cleanly...";
         i3($socketpath)->command('exit')->recv;
         $exited = 1;