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