]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blob - t/22-localize-block.t
fix unwind()
[perl/modules/Scope-Upper.git] / t / 22-localize-block.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use lib 't/lib';
7 use Test::Leaner 'no_plan';
8
9 use Scope::Upper qw<localize UP HERE>;
10
11 use Scope::Upper::TestGenerator;
12
13 local $Scope::Upper::TestGenerator::call = sub {
14  my ($height, $level, $i) = @_;
15  $level = $level ? 'UP ' x $level : 'HERE';
16  return [ "localize '\$x' => 0 => $level;\n" ];
17 };
18
19 local $Scope::Upper::TestGenerator::test = sub {
20  my ($height, $level, $i, $x) = @_;
21  my $j = ($i == $height - $level) ? 0 : (defined $x ? $x : 'undef');
22  return "verbose_is(\$x, $j, 'x h=$height, l=$level, i=$i');\n";
23 };
24
25 local $Scope::Upper::TestGenerator::local_test = sub { '' };
26
27 local $Scope::Upper::TestGenerator::allblocks = 1;
28
29 our ($x, $testcase);
30
31 for my $level (0 .. 1) {
32  my $height = $level + 1;
33  my $tests = Scope::Upper::TestGenerator::gen($height, $level);
34  for $testcase (@$tests) {
35   $x = undef;
36   eval $testcase;
37   diag $@ if $@;
38  }
39 }