whitespace
[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 tests => 2;
9 }
10
11 use Try::Tiny;
12
13 use 5.010;
14 no if "$]" >= 5.017011, warnings => 'experimental::smartmatch';
15
16 my ( $error, $topic );
17
18 given ("foo") {
19   when (qr/./) {
20     try {
21       die "blah\n";
22     } catch {
23       $topic = $_;
24       $error = $_[0];
25     }
26   };
27 }
28
29 is( $error, "blah\n", "error caught" );
30
31 {
32   local $TODO = "perhaps a workaround can be found"
33     if "$]" < 5.017003;
34   is( $topic, $error, 'error is also in $_' );
35 }
36
37 # ex: set sw=4 et: