bizarre smartmatch changes were removed in 5.27.10
[p5sagit/Try-Tiny.git] / t / given_when.t
CommitLineData
1a2992bb 1use strict;
2use warnings;
3
4use Test::More;
5
6BEGIN {
b715d61b 7 plan skip_all => 'Perl 5.010 is required' unless "$]" >= '5.010';
82559400 8 plan skip_all => 'Tests skipped on perl 5.27.{7,8,9} when smartmatch behaviour changed' if "$]" >= '5.027007' and "$]" < '5.027010';
c6d66f74 9 plan tests => 2;
1a2992bb 10}
11
01b96275 12use Try::Tiny;
13
73664e25 14use 5.010;
8c34b0ef 15no if "$]" >= 5.017011, warnings => 'experimental::smartmatch';
73664e25 16
1a2992bb 17my ( $error, $topic );
18
19given ("foo") {
8d2ee831 20 when (qr/./) {
21 try {
22 die "blah\n";
23 } catch {
24 $topic = $_;
25 $error = $_[0];
26 }
27 };
1a2992bb 28}
29
30is( $error, "blah\n", "error caught" );
31
32{
aaf0d61f 33 local $TODO = "perhaps a workaround can be found"
8c34b0ef 34 if "$]" < 5.017003;
8d2ee831 35 is( $topic, $error, 'error is also in $_' );
1a2992bb 36}
37
1a2992bb 38# ex: set sw=4 et: