Commit | Line | Data |
---|---|---|
1a2992bb | 1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | use Test::More; | |
7 | ||
8 | BEGIN { | |
8d2ee831 | 9 | plan skip_all => "Perl 5.10 is required" unless eval { require 5.010 }; |
10 | plan tests => 3; | |
11 | use_ok("Try::Tiny"); | |
1a2992bb | 12 | } |
13 | ||
73664e25 | 14 | use 5.010; |
f9d19a00 | 15 | no if $] >= 5.017011, warnings => 'experimental::smartmatch'; |
73664e25 | 16 | |
1a2992bb | 17 | my ( $error, $topic ); |
18 | ||
19 | given ("foo") { | |
8d2ee831 | 20 | when (qr/./) { |
21 | try { | |
22 | die "blah\n"; | |
23 | } catch { | |
24 | $topic = $_; | |
25 | $error = $_[0]; | |
26 | } | |
27 | }; | |
1a2992bb | 28 | } |
29 | ||
30 | is( $error, "blah\n", "error caught" ); | |
31 | ||
32 | { | |
8d2ee831 | 33 | local $TODO = "perhaps a workaround can be found"; |
34 | is( $topic, $error, 'error is also in $_' ); | |
1a2992bb | 35 | } |
36 | ||
1a2992bb | 37 | # ex: set sw=4 et: |
38 |