return "is(\$x, $j, 'x h=$height, l=$level, i=$i');\n";
};
-local $Scope::Upper::TestGenerator::local = sub {
+local $Scope::Upper::TestGenerator::local_decl = sub {
my ($height, $level, $i, $x) = @_;
return $i == $height - $level ? "\$x = $x;\n" : "local \$x = $x;\n";
};
-local $Scope::Upper::TestGenerator::testlocal = sub { '' };
+local $Scope::Upper::TestGenerator::local_test = sub { '' };
local $Scope::Upper::TestGenerator::allblocks = 1;
return "is(\$x, $j, 'x h=$height, l=$level, i=$i');\n";
};
-local $Scope::Upper::TestGenerator::testlocal = sub { '' };
+local $Scope::Upper::TestGenerator::local_test = sub { '' };
local $Scope::Upper::TestGenerator::allblocks = 1;
use Scope::Upper::TestGenerator;
-local $Scope::Upper::TestGenerator::testlocal = sub { '' };
+our $testcase;
-local $Scope::Upper::TestGenerator::allblocks = 1;
+local $Scope::Upper::TestGenerator::local_test = sub { '' };
-our $testcase;
+local $Scope::Upper::TestGenerator::allblocks = 1;
local $Scope::Upper::TestGenerator::call = sub {
my ($height, $level, $i) = @_;
return "is(\$a[1], $j, 'x h=$height, l=$level, i=$i');\n";
};
-local $Scope::Upper::TestGenerator::local = sub {
- my $x = $_[3];
- return "local \$a[1] = $x;\n";
-};
+local $Scope::Upper::TestGenerator::local_var = '$a[1]';
our @a;
return "is(\$h{a}, $j, 'x h=$height, l=$level, i=$i');\n";
};
-local $Scope::Upper::TestGenerator::local = sub {
- my $x = $_[3];
- return "local \$h{a} = $x;\n";
-};
+local $Scope::Upper::TestGenerator::local_var = '$h{a}';
our %h;
use strict;
use warnings;
-our ($call, $test, $local, $testlocal, $allblocks);
+our ($call, $test, $allblocks);
-$local = sub {
+our $local_var = '$x';
+
+our $local_decl = sub {
+ my $x = $_[3];
+ return "local $local_var = $x;\n";
+};
+
+our $local_cond = sub {
my $x = $_[3];
- return "local \$x = $x;\n";
+ return defined $x ? "($local_var eq $x)" : "(!defined($local_var))";
};
-$testlocal = sub {
+our $local_test = sub {
my ($height, $level, $i, $x) = @_;
- my $j = defined $x ? $x : 'undef';
- return "is(\$x, $j, 'x h=$height, l=$level, i=$i');\n";
+ my $cond = $local_cond->(@_);
+ return "ok($cond, 'local h=$height, l=$level, i=$i');\n";
};
my @blocks = (
my $up = gen($height, $level, $i + 1, $x);
for my $base (@$up) {
for my $blk (@blks) {
- push @res, $blk->[0] . $base . $test->(@_) . $testlocal->(@_) . $blk->[1];
+ push @res, $blk->[0] . $base . $test->(@_) . $local_test->(@_) . $blk->[1];
}
}
$_[3] = $i + 1;
for my $base (@$up) {
for my $blk (@blks) {
push @res, $blk->[0] .
- $local->(@_) . $base . $test->(@_) . $testlocal->(@_)
+ $local_decl->(@_) . $base . $test->(@_) . $local_test->(@_)
. $blk->[1];
}
}