Commit | Line | Data |
---|---|---|
3176feef | 1 | use strict; |
f9d19a00 | 2 | use warnings; |
3176feef | 3 | |
4 | use Test::More; | |
5 | ||
6 | BEGIN { | |
b715d61b | 7 | plan skip_all => 'Perl 5.010 is required' unless "$]" >= '5.010'; |
c6d66f74 | 8 | plan tests => 5; |
3176feef | 9 | } |
10 | ||
01b96275 | 11 | use Try::Tiny; |
3176feef | 12 | |
13 | use 5.010; | |
8c34b0ef | 14 | no if "$]" >= 5.017011, warnings => 'experimental::smartmatch'; |
3176feef | 15 | |
16 | my ( $foo, $bar, $other ); | |
17 | ||
18 | $_ = "magic"; | |
19 | ||
20 | try { | |
8d2ee831 | 21 | die "foo"; |
3176feef | 22 | } catch { |
23 | ||
8d2ee831 | 24 | like( $_, qr/foo/ ); |
3176feef | 25 | |
8d2ee831 | 26 | when (/bar/) { $bar++ }; |
27 | when (/foo/) { $foo++ }; | |
28 | default { $other++ }; | |
3176feef | 29 | }; |
30 | ||
31 | is( $_, "magic", '$_ not clobbered' ); | |
32 | ||
33 | ok( !$bar, "bar didn't match" ); | |
34 | ok( $foo, "foo matched" ); | |
35 | ok( !$other, "fallback didn't match" ); |