X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2Flib%2FScope%2FUpper%2FTestGenerator.pm;h=df175acf540437ed4f509e9a796fb56617fdd819;hb=ef4ac48db70f6d8dcaa21e6b67e7fbec7a50cf7b;hp=0b3a8e631433eb7a4cffb8e5387b4f041b576f00;hpb=c51f72ece23a7afb5590272f6aeca327b91a3945;p=perl%2Fmodules%2FScope-Upper.git diff --git a/t/lib/Scope/Upper/TestGenerator.pm b/t/lib/Scope/Upper/TestGenerator.pm index 0b3a8e6..df175ac 100644 --- a/t/lib/Scope/Upper/TestGenerator.pm +++ b/t/lib/Scope/Upper/TestGenerator.pm @@ -32,16 +32,48 @@ my @blocks = ( [ 'eval q[', '];' ], ); +push @blocks, [ 'given (1) {', '}' ] if "$]" >= 5.010_001 and "$]" < 5.037_010; + +my %exports = ( + verbose_is => \&verbose_is, +); + sub import { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + if ("$]" >= 5.010_001) { - push @blocks, [ 'given (1) {', '}' ]; require feature; feature->import('switch'); } + + my $pkg = caller; + while (my ($name, $code) = each %exports) { + no strict 'refs'; + *{$pkg.'::'.$name} = $code; + } } @blocks = map [ map "$_\n", @$_ ], @blocks; +sub verbose_is ($$;$) { + my ($a, $b, $desc) = @_; + + if (defined $::testcase + and (defined $b) ? (not defined $a or $a ne $b) : defined $a) { + Test::Leaner::diag(<(@_) if $height < $i; + my @res; my @blks = $allblocks ? @blocks : _block(@_); + my $up = gen($height, $level, $i + 1, $x); + my $t = $test->(@_); + my $loct = $local_test->(@_); for my $base (@$up) { for my $blk (@blks) { - push @res, $blk->[0] . $base . $test->(@_) . $local_test->(@_) . $blk->[1]; + push @res, join '', $blk->[0], $base, $t, $loct, $blk->[1]; } } - $_[3] = $i + 1; - $up = gen($height, $level, $i + 1, $i + 1); + + $_[3] = $x = $i + 1; + $up = gen($height, $level, $i + 1, $x); + $t = $test->(@_); + my $locd = $local_decl->(@_); + $loct = $local_test->(@_); for my $base (@$up) { for my $blk (@blks) { - push @res, $blk->[0] . - $local_decl->(@_) . $base . $test->(@_) . $local_test->(@_) - . $blk->[1]; + push @res, join '', $blk->[0], $locd, $base, $t, $loct, $blk->[1]; } } + return \@res; }