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