X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FSub-Op.git;a=blobdiff_plain;f=t%2F11-existing.t;h=6c2e9ba75664d61c3ce226eefbf8c8010cf97872;hp=2e6c6ca11a424a372f23e54c249e309926e70ad0;hb=e7ec7b5660437ed920a2d671f933d8db331e27d0;hpb=3571f5a5bbffc758bbb91793ae256609d71945fc diff --git a/t/11-existing.t b/t/11-existing.t index 2e6c6ca..6c2e9ba 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 * ((2 + 2) * 4 + (1 + 2) * 5) + (2 + 2) + 4; +use Test::More tests => 2 * ((2 + 2) * 4 + (1 + 2) * 5) + 2 * (2 + 2) + 4; our $call_foo; sub foo { ok $call_foo, 'the preexistent foo was called' } @@ -15,6 +15,9 @@ sub bar () { ok $call_bar, 'the preexistent bar was called' } sub X () { 1 } +our $call_blech; +sub blech { ok $call_blech, 'initial blech was called' }; + our $called; { @@ -59,7 +62,7 @@ our $called; } $test .= "{\n$code\n}\n"; $test .= "}\n"; - for my $name (grep +{ map +($_, 1), qw/foo bar/ }->{ $_ }, @names) { + for my $name (grep +{ map +($_, 1), qw/foo bar blech/ }->{ $_ }, @names) { $test .= <<" CHECK_SUB" { local \$call_$name = 1; @@ -179,3 +182,11 @@ bar # () # is X, 2, 'constant overriding'; ---- X # 2 # [ ] +#### +no warnings 'redefine'; +sub blech { fail 'redefined blech was called' } +BEGIN { $call_blech = 0 } +blech 7; +BEGIN { $call_blech = 1 } +---- +blech # () # [ 7 ]