1 package Scope::Upper::TestGenerator;
6 our ($call, $test, $allblocks);
10 our $local_decl = sub {
12 return "local $local_var = $x;\n";
15 our $local_cond = sub {
17 return defined $x ? "($local_var eq $x)" : "(!defined($local_var))";
20 our $local_test = sub {
21 my ($height, $level, $i, $x) = @_;
22 my $cond = $local_cond->(@_);
23 return "ok($cond, 'local h=$height, l=$level, i=$i');\n";
28 [ 'sub {', '}->();' ],
36 if ("$]" >= 5.010_001) {
37 push @blocks, [ 'given (1) {', '}' ];
39 feature->import('switch');
43 @blocks = map [ map "$_\n", @$_ ], @blocks;
46 my ($height, $level, $i) = @_;
48 $j = 0 if $j > $#blocks or $j < 0;
49 return [ map "$_\n", @{$blocks[$j]} ];
53 my ($height, $level, $i, $x) = @_;
60 return $call->(@_) if $height < $i;
63 my @blks = $allblocks ? @blocks : _block(@_);
65 my $up = gen($height, $level, $i + 1, $x);
67 my $loct = $local_test->(@_);
70 push @res, join '', $blk->[0], $base, $t, $loct, $blk->[1];
75 $up = gen($height, $level, $i + 1, $x);
77 my $locd = $local_decl->(@_);
78 $loct = $local_test->(@_);
81 push @res, join '', $blk->[0], $locd, $base, $t, $loct, $blk->[1];