From: Peter Rabbitson Date: Thu, 4 Jul 2013 04:12:42 +0000 (+0200) Subject: "Modernize" code a bit X-Git-Tag: Try-Tiny-0.13~6^2~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f9d19a00aabbd2c4e62f6c1b833016822ac5492a;p=p5sagit%2FTry-Tiny.git "Modernize" code a bit Turn on warnings everywhere (5.6 being lowest target) Silence experimental warnings in given/when tests --- diff --git a/lib/Try/Tiny.pm b/lib/Try/Tiny.pm index 6f892c6..229c3c8 100644 --- a/lib/Try/Tiny.pm +++ b/lib/Try/Tiny.pm @@ -1,21 +1,15 @@ package Try::Tiny; use strict; -#use warnings; +use warnings; -use vars qw(@EXPORT @EXPORT_OK $VERSION @ISA); +our $VERSION = "0.12"; +$VERSION = eval $VERSION if $VERSION =~ /_/; -BEGIN { - require Exporter; - @ISA = qw(Exporter); -} - -$VERSION = "0.12"; - -$VERSION = eval $VERSION; - -@EXPORT = @EXPORT_OK = qw(try catch finally); +use base 'Exporter'; +our @EXPORT = our @EXPORT_OK = qw(try catch finally); +use Carp; $Carp::Internal{+__PACKAGE__}++; # Need to prototype as @ not $$ because of the way Perl evaluates the prototype. @@ -43,7 +37,6 @@ sub try (&;@) { } elsif ( $ref eq 'Try::Tiny::Finally' ) { push @finally, ${$code_ref}; } else { - use Carp; confess("Unknown code ref type given '${ref}'. Check your usage & try again"); } } diff --git a/t/basic.t b/t/basic.t index fea3c5c..7552721 100644 --- a/t/basic.t +++ b/t/basic.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; -#use warnings; +use warnings; use Test::More tests => 26; diff --git a/t/finally.t b/t/finally.t index bbc4e0e..789d80c 100644 --- a/t/finally.t +++ b/t/finally.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; -#use warnings; +use warnings; use Test::More tests => 24; diff --git a/t/given_when.t b/t/given_when.t index 4ae9baa..49e11ac 100644 --- a/t/given_when.t +++ b/t/given_when.t @@ -12,6 +12,7 @@ BEGIN { } use 5.010; +no if $] >= 5.017011, warnings => 'experimental::smartmatch'; my ( $error, $topic ); diff --git a/t/when.t b/t/when.t index ea5b772..d67fe95 100644 --- a/t/when.t +++ b/t/when.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; -#use warnings; +use warnings; use Test::More; @@ -14,6 +14,7 @@ BEGIN { BEGIN { use_ok 'Try::Tiny' } use 5.010; +no if $] >= 5.017011, warnings => 'experimental::smartmatch'; my ( $foo, $bar, $other );