push to both repos on release
[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';
c8e3a471 9 plan skip_all => 'given/when have been removed in perl 5.42' if "$]" >= '5.041003';
c6d66f74 10 plan tests => 2;
1a2992bb 11}
12
01b96275 13use Try::Tiny;
14
73664e25 15use 5.010;
8c34b0ef 16no if "$]" >= 5.017011, warnings => 'experimental::smartmatch';
73664e25 17
1a2992bb 18my ( $error, $topic );
19
20given ("foo") {
8d2ee831 21 when (qr/./) {
22 try {
23 die "blah\n";
24 } catch {
25 $topic = $_;
26 $error = $_[0];
27 }
28 };
1a2992bb 29}
30
31is( $error, "blah\n", "error caught" );
32
33{
aaf0d61f 34 local $TODO = "perhaps a workaround can be found"
8c34b0ef 35 if "$]" < 5.017003;
8d2ee831 36 is( $topic, $error, 'error is also in $_' );
1a2992bb 37}
38
1a2992bb 39# ex: set sw=4 et: