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 {', '}->();' ],
29 if ("$]" >= 5.010001) {
30 push @blocks, [ 'given (1) {', '}' ];
32 feature->import('switch');
36 @blocks = map [ map "$_\n", @$_ ], @blocks;
39 my ($height, $level, $i) = @_;
41 $j = 0 if $j > $#blocks or $j < 0;
42 return [ map "$_\n", @{$blocks[$j]} ];
46 my ($height, $level, $i, $x) = @_;
47 push @_, $i = 0 if @_ == 2;
48 return $call->(@_) if $height < $i;
50 my @blks = $allblocks ? @blocks : _block(@_);
51 my $up = gen($height, $level, $i + 1, $x);
54 push @res, $blk->[0] . $base . $test->(@_) . $testlocal->(@_) . $blk->[1];
58 $up = gen($height, $level, $i + 1, $i + 1);
61 push @res, $blk->[0] .
62 $local->(@_) . $base . $test->(@_) . $testlocal->(@_)