]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blob - t/50-unwind-target.t
fix unwind()
[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 => 6;
7
8 use Scope::Upper qw<unwind>;
9
10 my @res;
11
12 @res = (7, eval {
13  unwind;
14  8;
15 });
16 is $@, '', 'unwind() does not croak';
17 is_deeply \@res, [ 7 ], 'unwind()';
18
19 @res = (7, eval {
20  unwind -1;
21  8;
22 });
23 like $@, qr/^Can't\s+return\s+outside\s+a\s+subroutine/, 'unwind(-1) croaks';
24 is_deeply \@res, [ 7 ], 'unwind(-1)';
25
26 @res = (7, eval {
27  unwind 0;
28  8;
29 });
30 like $@, qr/^Can't\s+return\s+outside\s+a\s+subroutine/, 'unwind(0) croaks';
31 is_deeply \@res, [ 7 ], 'unwind(0)';