just skip when tests on all perls since when changed to whereis/whereso
[p5sagit/Try-Tiny.git] / t / when.t
CommitLineData
3176feef 1use strict;
f9d19a00 2use warnings;
3176feef 3
4use Test::More;
5
6BEGIN {
b715d61b 7 plan skip_all => 'Perl 5.010 is required' unless "$]" >= '5.010';
3b23a067 8 plan skip_all => 'Tests skipped on perl 5.27.7+, pending resolution of smartmatch changes' if "$]" >= '5.027007';
c6d66f74 9 plan tests => 5;
3176feef 10}
11
01b96275 12use Try::Tiny;
3176feef 13
14use 5.010;
8c34b0ef 15no if "$]" >= 5.017011, warnings => 'experimental::smartmatch';
3176feef 16
17my ( $foo, $bar, $other );
18
19$_ = "magic";
20
21try {
8d2ee831 22 die "foo";
3176feef 23} catch {
24
8d2ee831 25 like( $_, qr/foo/ );
3176feef 26
8d2ee831 27 when (/bar/) { $bar++ };
28 when (/foo/) { $foo++ };
29 default { $other++ };
3176feef 30};
31
32is( $_, "magic", '$_ not clobbered' );
33
34ok( !$bar, "bar didn't match" );
35ok( $foo, "foo matched" );
36ok( !$other, "fallback didn't match" );