blob: df7460a3cf15bdd3ac7770aececd3c1a2390df6c (
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
34
35
36
37
38
39
40
|
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use lib 't/try/lib';
use 5.014;
BEGIN {
if (!eval { require Try::Tiny }) {
plan skip_all => "This test requires Try::Tiny";
}
}
no if $] >= 5.018, warnings => 'experimental::smartmatch';
use Try;
my ( $error, $topic );
given ("foo") {
when (qr/./) {
try {
die "blah\n";
} catch {
$topic = $_;
$error = $_[0];
}
pass("syntax ok");
};
}
is( $error, "blah\n", "error caught" );
{
local $TODO = "perhaps a workaround can be found"
if $] < 5.018;
is( $topic, $error, 'error is also in $_' );
}
done_testing;
|