1 package Scope::Upper::TestGenerator;
6 our ($call, $test, $local, $testlocal, $allblocks);
10 return "local \$x = $x;\n";
14 my ($height, $level, $i, $x) = @_;
15 my $j = defined $x ? $x : 'undef';
16 return "is(\$x, $j, 'x h=$height, l=$level, i=$i');\n";
21 [ 'sub {', '}->();' ],
28 @blocks = map [ map "$_\n", @$_ ], @blocks;
31 my ($height, $level, $i) = @_;
33 $j = 0 if $j > $#blocks or $j < 0;
34 return [ map "$_\n", @{$blocks[$j]} ];
38 my ($height, $level, $i, $x) = @_;
39 push @_, $i = 0 if @_ == 2;
40 return $call->(@_) if $height < $i;
42 my @blks = $allblocks ? @blocks : _block(@_);
43 my $up = gen($height, $level, $i + 1, $x);
46 push @res, $blk->[0] . $base . $test->(@_) . $testlocal->(@_) . $blk->[1];
50 $up = gen($height, $level, $i + 1, $i + 1);
53 push @res, $blk->[0] .
54 $local->(@_) . $base . $test->(@_) . $testlocal->(@_)