X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2Flib%2FScope%2FUpper%2FTestGenerator.pm;h=0b3a8e631433eb7a4cffb8e5387b4f041b576f00;hb=c51f72ece23a7afb5590272f6aeca327b91a3945;hp=9ef65b8849474977047cd193d473d7755520c9ac;hpb=6d9ec3d17a2589cf3a259893f7ae752f5474ecf5;p=perl%2Fmodules%2FScope-Upper.git diff --git a/t/lib/Scope/Upper/TestGenerator.pm b/t/lib/Scope/Upper/TestGenerator.pm index 9ef65b8..0b3a8e6 100644 --- a/t/lib/Scope/Upper/TestGenerator.pm +++ b/t/lib/Scope/Upper/TestGenerator.pm @@ -3,17 +3,24 @@ package Scope::Upper::TestGenerator; 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 = ( @@ -51,7 +58,7 @@ sub gen { 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; @@ -59,7 +66,7 @@ sub gen { for my $base (@$up) { for my $blk (@blks) { push @res, $blk->[0] . - $local->(@_) . $base . $test->(@_) . $testlocal->(@_) + $local_decl->(@_) . $base . $test->(@_) . $local_test->(@_) . $blk->[1]; } }