X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F11-existing.t;h=ecc673ef7738745f6d94bff143f8d2410f4f9ac2;hb=c38db653bec41568fc1caab3c19763e7ed2e5a2b;hp=fae36fc9bd755120e555ad6f5dd20dd0799560e3;hpb=c8f39d20852c85f99aabd8c3df4fb354678c8e99;p=perl%2Fmodules%2FSub-Op.git diff --git a/t/11-existing.t b/t/11-existing.t index fae36fc..ecc673e 100644 --- a/t/11-existing.t +++ b/t/11-existing.t @@ -3,18 +3,24 @@ use strict; use warnings; -use blib 't/Sub-Op-Test'; +use blib 't/Sub-Op-LexicalSub'; -use Test::More tests => (4 + 2 * 4) + (2 * 5); +use Test::More tests => 2 *((4 + 2 * 4) + (2 * 5) + 1); our $call_foo; sub foo { ok $call_foo, 'the preexistent foo was called' } +our $call_bar; +sub bar () { ok $call_bar, 'the preexistent bar was called' } + our $called; { local $/ = "####\n"; while () { + chomp; + s/\s*$//; + my ($code, $params) = split /----\s*/, $_; my ($names, $ret, $exp, $seq) = split /\s*#\s*/, $params; @@ -39,7 +45,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'; @@ -66,6 +72,9 @@ our $called; } } +is prototype('main::foo'), undef, "foo's prototype was preserved"; +is prototype('main::bar'), '', "bar's prototype was preserved"; + __DATA__ foo(); ---- @@ -109,3 +118,46 @@ my $foo = \&foo; &$foo; ---- foo # () # +#### +bar(); +---- +bar # () # [ ] +#### +bar; +---- +bar # () # [ ] +#### +bar(1); +---- +bar # () # [ 1 ] +#### +bar 2; +---- +bar # () # [ 2 ] +#### +local $call_bar = 1; +&bar(); +---- +bar # () # +#### +local $call_bar = 1; +&bar; +---- +bar # () # +#### +local $call_bar = 1; +&bar(3); +---- +bar # () # +#### +local $call_bar = 1; +my $bar = \&bar; +$bar->(); +---- +bar # () # +#### +local $call_bar = 1; +my $bar = \&bar; +&$bar; +---- +bar # () #