X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F11-existing.t;h=749fff136fa63311fd3925a2032b383dc6b2dd6a;hb=a3c83d0adc138681da18079c268948d2fe9326d7;hp=0339bc850b391436f5fe1d7beb6bf97071f58562;hpb=5ae3324ff295015e051249ded13b2353ee8af258;p=perl%2Fmodules%2FSub-Op.git diff --git a/t/11-existing.t b/t/11-existing.t index 0339bc8..749fff1 100644 --- a/t/11-existing.t +++ b/t/11-existing.t @@ -5,7 +5,7 @@ use warnings; use blib 't/Sub-Op-LexicalSub'; -use Test::More tests => 2 *((4 + 2 * 4) + (2 * 5) + 1); +use Test::More tests => 2 * ((1 + 2) * 4 + (1 + 1) * 5) + (2 + 2) + 4; our $call_foo; sub foo { ok $call_foo, 'the preexistent foo was called' } @@ -13,11 +13,16 @@ sub foo { ok $call_foo, 'the preexistent foo was called' } our $call_bar; sub bar () { ok $call_bar, 'the preexistent bar was called' } +sub X () { 1 } + our $called; { local $/ = "####\n"; while () { + chomp; + s/\s*$//; + my ($code, $params) = split /----\s*/, $_; my ($names, $ret, $exp, $seq) = split /\s*#\s*/, $params; @@ -64,13 +69,16 @@ 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; } } } is prototype('main::foo'), undef, "foo's prototype was preserved"; is prototype('main::bar'), '', "bar's prototype was preserved"; +is prototype('main::X'), '', "X's prototype was preserved"; +ok Sub::Op::_constant_sub(do { no strict "refs"; \&{"main::X"} }), + 'X is still a constant'; __DATA__ foo(); @@ -158,3 +166,7 @@ my $bar = \&bar; &$bar; ---- bar # () # +#### +is X, 2, 'constant overriding'; +---- +X # 2 # [ ]