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