X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F10-base.t;h=6e6b5d12eeb0f0877693bde8e734e81bca103666;hb=e807a54178bf762ae4b6f764be5c0d6a3df60fcb;hp=1f785e5b4897e9ef9d746edcbba9f6919893677f;hpb=3b39085a294ef16114b0d119dc8ebdecbe87fb51;p=perl%2Fmodules%2FSub-Op.git diff --git a/t/10-base.t b/t/10-base.t index 1f785e5..6e6b5d1 100644 --- a/t/10-base.t +++ b/t/10-base.t @@ -3,15 +3,18 @@ use strict; use warnings; -use blib 't/Sub-Op-Test'; +use blib 't/Sub-Op-LexicalSub'; -use Test::More tests => 2 * 15 + 3 * 2 + 2 * 28; +use Test::More tests => (1 + 3) * 16 + (1 + 2 * 3) * 2 + 2 * 29; our $called; { local $/ = "####\n"; while () { + chomp; + s/\s*$//; + my ($code, $params) = split /----\s*/, $_; my ($names, $ret, $exp, $seq) = split /\s*#\s*/, $params; @@ -36,7 +39,7 @@ our $called; my $test = "{\n"; for my $name (@names) { $test .= <<" INIT" - use Sub::Op::Test $name => sub { + use Sub::Op::LexicalSub $name => sub { ++\$called; my \$exp = shift \@exp; is_deeply \\\@_, \$exp, '$name: arguments are correct'; @@ -51,7 +54,9 @@ our $called; $test .= <<" CHECK_VIVID" BEGIN { no warnings 'uninitialized'; # Test::Builder can't get the file name - is *main::${name}\{CODE\}, undef, '$name: no symbol table vivification'; + ok !exists &main::${name}, '$name: not stubbed'; + ok !defined &main::${name}, '$name: body not defined'; + is *main::${name}\{CODE\}, undef, '$name: empty symbol table entry'; } CHECK_VIVID } @@ -66,7 +71,7 @@ our $called; is $called, $calls, "@names: the hook was called the right number of times"; if ($called < $calls) { - fail for $called + 1 .. $calls; + fail, fail for $called + 1 .. $calls; } } } @@ -123,6 +128,16 @@ fetch 1, do { no strict 'refs'; *{__PACKAGE__.'::fetch'}{CODE} }, 2 ---- fetch # () # [ 1, undef, 2 ] #### +my ($cb, $err); +BEGIN { + $cb = do { no strict 'refs'; \&{__PACKAGE__.'::cvref'} }; + eval { $cb->() }; + $err = $@ =~ /^Undefined subroutine &main::cvref/ ? undef : $@; +} +cvref $err; +---- +cvref # () # [ undef ] +#### our $scalr = 1; scalr $scalr; ----