blob: 6a0c0754248215b4c2b5b1ab0661b6d0e77e7cf0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use lib 't/try/lib';
use 5.014;
no if $] >= 5.018, warnings => 'experimental::smartmatch';
use Try;
my ( $foo, $bar, $other );
$_ = "magic";
try {
die "foo";
} catch {
like( $_, qr/foo/ );
when (/bar/) { $bar++ };
when (/foo/) { $foo++ };
default { $other++ };
}
is( $_, "magic", '$_ not clobbered' );
ok( !$bar, "bar didn't match" );
ok( $foo, "foo matched" );
ok( !$other, "fallback didn't match" );
done_testing;
|