update tooling to avoid detecting the optional use of perl 5.010
[p5sagit/Try-Tiny.git] / t / when.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 BEGIN {
9   plan skip_all => 'Perl 5.010 is required' unless "$]" >= '5.010';
10   plan tests => 5;
11 }
12
13 use Try::Tiny;
14
15 use 5.010;
16 no if $] >= 5.017011, warnings => 'experimental::smartmatch';
17
18 my ( $foo, $bar, $other );
19
20 $_ = "magic";
21
22 try {
23   die "foo";
24 } catch {
25
26   like( $_, qr/foo/ );
27
28   when (/bar/) { $bar++ };
29   when (/foo/) { $foo++ };
30   default { $other++ };
31 };
32
33 is( $_, "magic", '$_ not clobbered' );
34
35 ok( !$bar, "bar didn't match" );
36 ok( $foo, "foo matched" );
37 ok( !$other, "fallback didn't match" );