test for finally{} getting the error
[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 => 3;
11     use_ok("Try::Tiny");
12 }
13
14 my ( $error, $topic );
15
16 given ("foo") {
17     when (qr/./) {
18         try {
19             die "blah\n";
20         } catch {
21             $topic = $_;
22             $error = $_[0];
23         }
24     };
25 }
26
27 is( $error, "blah\n", "error caught" );
28
29 {
30     local $TODO = "perhaps a workaround can be found";
31     is( $topic, $error, 'error is also in $_' );
32 }
33
34 # ex: set sw=4 et:
35