X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2Flib%2FScope%2FUpper%2FTestGenerator.pm;h=c71b8f36f2f7c925f79b0679a2b56fe8501e28f6;hb=824b421b73e313d2eb4fd950c231272c1a52ed58;hp=8415632cc349a3a6859d53572f2f0ba3fe7f9d27;hpb=95dcbf868547141c0b022c55cf8e79498edf12d9;p=perl%2Fmodules%2FScope-Upper.git diff --git a/t/lib/Scope/Upper/TestGenerator.pm b/t/lib/Scope/Upper/TestGenerator.pm index 8415632..c71b8f3 100644 --- a/t/lib/Scope/Upper/TestGenerator.pm +++ b/t/lib/Scope/Upper/TestGenerator.pm @@ -32,16 +32,43 @@ my @blocks = ( [ 'eval q[', '];' ], ); +push @blocks, [ 'given (1) {', '}' ] if "$]" >= 5.010_001; + +my %exports = ( + verbose_is => \&verbose_is, +); + sub import { 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(<