X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F11-existing.t;h=6c2e9ba75664d61c3ce226eefbf8c8010cf97872;hb=e7ec7b5660437ed920a2d671f933d8db331e27d0;hp=749fff136fa63311fd3925a2032b383dc6b2dd6a;hpb=a3c83d0adc138681da18079c268948d2fe9326d7;p=perl%2Fmodules%2FSub-Op.git diff --git a/t/11-existing.t b/t/11-existing.t index 749fff1..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 * ((1 + 2) * 4 + (1 + 1) * 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; { @@ -44,7 +47,7 @@ our $called; @seq = ($names[0]) x $calls; } - my $test = "{\n"; + my $test = "{\n{\n"; for my $name (@names) { $test .= <<" INIT" use Sub::Op::LexicalSub $name => sub { @@ -59,6 +62,15 @@ our $called; } $test .= "{\n$code\n}\n"; $test .= "}\n"; + for my $name (grep +{ map +($_, 1), qw/foo bar blech/ }->{ $_ }, @names) { + $test .= <<" CHECK_SUB" + { + local \$call_$name = 1; + $name(); + } + CHECK_SUB + } + $test .= "}\n"; local $called = 0; eval $test; @@ -170,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 ]