fix tests failing on 5.6.x due to differing DESTROY semantics
[p5sagit/Try-Tiny.git] / t / when.t
CommitLineData
3176feef 1#!/usr/bin/perl
2
3use strict;
ae53da51 4#use warnings;
3176feef 5
6use Test::More;
7
8BEGIN {
8d2ee831 9 plan skip_all => "Perl 5.10 required" unless eval { require 5.010; 1 };
10 plan tests => 6;
3176feef 11}
12
13
14BEGIN { use_ok 'Try::Tiny' }
15
16use 5.010;
17
18my ( $foo, $bar, $other );
19
20$_ = "magic";
21
22try {
8d2ee831 23 die "foo";
3176feef 24} catch {
25
8d2ee831 26 like( $_, qr/foo/ );
3176feef 27
8d2ee831 28 when (/bar/) { $bar++ };
29 when (/foo/) { $foo++ };
30 default { $other++ };
3176feef 31};
32
33is( $_, "magic", '$_ not clobbered' );
34
35ok( !$bar, "bar didn't match" );
36ok( $foo, "foo matched" );
37ok( !$other, "fallback didn't match" );