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