]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blob - t/50-unwind-target.t
9ef70ecf7a213fc80c99621d455b7389c6f7d452
[perl/modules/Scope-Upper.git] / t / 50-unwind-target.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 4;
7
8 use Scope::Upper qw<unwind>;
9
10 my @res;
11
12 @res = (7, eval {
13  unwind;
14  8;
15 });
16 is_deeply \@res, [ 7 ], 'unwind()';
17
18 @res = (7, eval {
19  unwind -1;
20  8;
21 });
22 is_deeply \@res, [ 7 ], 'unwind(-1)';
23
24 @res = (7, eval {
25  unwind 0;
26  8;
27 });
28 like $@, qr/^Can't\s+return\s+outside\s+a\s+subroutine/, 'unwind(0) croaks';
29 is_deeply \@res, [ 7 ], 'unwind(0)';