X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=t%2F20-good.t;h=353949893fe4d9fdb2117ba5b4c393638fe5e9ec;hp=0f482a55cf0a3bce2d3026b11fa39457e8215261;hb=e11d9a3efc1dcc5648202bd7651a982477bbc587;hpb=ff16be2f69592b80dfcbc397b37dd4ea070b9d62 diff --git a/t/20-good.t b/t/20-good.t index 0f482a5..3539498 100644 --- a/t/20-good.t +++ b/t/20-good.t @@ -9,12 +9,26 @@ package main; use strict; use warnings; -use Test::More tests => 56 * 4; +use Test::More tests => 56 * 8; + +BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} } my ($obj, $pkg, $cb, $x, @a); our $y; sub meh; -sub try (&); +sub zap (&); + +my @warns; + +sub try { + my ($code) = @_; + + @warns = (); + { + local $SIG{__WARN__} = sub { push @warns, @_ }; + eval $code; + } +} { local $/ = "####"; @@ -29,23 +43,30 @@ sub try (&); SKIP: { - skip "$_: $skip" => 4 if eval $skip; - - local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; - - eval "die qq{ok\\n}; $prefix; use indirect; $_"; - is($@, "ok\n", "use indirect: $_"); - - eval "die qq{ok\n}; $prefix; no indirect; $_"; - is($@, "ok\n", "no indirect: $_"); - - s/Hlagh/Dongs/g; - - eval "die qq{ok\\n}; $prefix; use indirect; $_"; - is($@, "ok\n", "use indirect, defined: $_"); - - eval "die qq{ok\\n}; $prefix; no indirect; $_"; - is($@, "ok\n", "no indirect, defined: $_"); + skip "$_: $skip" => 8 if eval $skip; + + { + try "return; $prefix; use indirect; $_"; + is $@, '', "use indirect: $_"; + is @warns, 0, 'no reports'; + + try "return; $prefix; no indirect; $_"; + is $@, '', "no indirect: $_"; + is @warns, 0, 'no reports'; + } + + { + local $_ = $_; + s/Hlagh/Dongs/g; + + try "return; $prefix; use indirect; $_"; + is $@, '', "use indirect, defined: $_"; + is @warns, 0, 'no reports'; + + try "return; $prefix; no indirect; $_"; + is $@, '', "no indirect, defined: $_"; + is @warns, 0, 'no reports'; + } } } } @@ -178,10 +199,10 @@ system $x $x, @a; #### system { $a[0] } @a; #### -try { }; +zap { }; #### -try { 1; }; +zap { 1; }; #### -try { 1; 1; }; +zap { 1; 1; }; #### -try { try { }; 1; }; +zap { zap { }; 1; };