X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=t%2F20-good.t;fp=t%2F20-good.t;h=4a7c3a0fa0fa6e7860787e759ac4e0725860e5de;hp=87e53cb010b298a0b5fd93cd86d5f0ea4001ad97;hb=c7b10fa5c0fe7243236bf0efa9a33776bafdc5c1;hpb=a14a12252b6c78b0f231e4d5e05480c90caac29c diff --git a/t/20-good.t b/t/20-good.t index 87e53cb..4a7c3a0 100644 --- a/t/20-good.t +++ b/t/20-good.t @@ -9,13 +9,25 @@ package main; use strict; use warnings; -use Test::More tests => 56 * 4; +use Test::More tests => 56 * 8; my ($obj, $pkg, $cb, $x, @a); our $y; sub meh; sub zap (&); +my @warns; + +sub try { + my ($code) = @_; + + @warns = (); + { + local $SIG{__WARN__} = sub { push @warns, @_ }; + eval $code; + } +} + { local $/ = "####"; while () { @@ -29,23 +41,30 @@ sub zap (&); 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'; + } } } }