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'; |
3b23a067 |
8 | plan skip_all => 'Tests skipped on perl 5.27.7+, pending resolution of smartmatch changes' if "$]" >= '5.027007'; |
c6d66f74 |
9 | plan tests => 5; |
3176feef |
10 | } |
11 | |
01b96275 |
12 | use Try::Tiny; |
3176feef |
13 | |
14 | use 5.010; |
8c34b0ef |
15 | no if "$]" >= 5.017011, warnings => 'experimental::smartmatch'; |
3176feef |
16 | |
17 | my ( $foo, $bar, $other ); |
18 | |
19 | $_ = "magic"; |
20 | |
21 | try { |
8d2ee831 |
22 | die "foo"; |
3176feef |
23 | } catch { |
24 | |
8d2ee831 |
25 | like( $_, qr/foo/ ); |
3176feef |
26 | |
8d2ee831 |
27 | when (/bar/) { $bar++ }; |
28 | when (/foo/) { $foo++ }; |
29 | default { $other++ }; |
3176feef |
30 | }; |
31 | |
32 | is( $_, "magic", '$_ not clobbered' ); |
33 | |
34 | ok( !$bar, "bar didn't match" ); |
35 | ok( $foo, "foo matched" ); |
36 | ok( !$other, "fallback didn't match" ); |