From: Vincent Pit Date: Tue, 14 Jul 2009 15:42:29 +0000 (+0200) Subject: Freshen t/22-bad-mixed.t X-Git-Tag: v0.16~5 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=cbecf892237be67b5072837d7691557f8f1751e2;p=perl%2Fmodules%2Findirect.git Freshen t/22-bad-mixed.t --- diff --git a/t/22-bad-mixed.t b/t/22-bad-mixed.t index 4462bf6..57282e2 100644 --- a/t/22-bad-mixed.t +++ b/t/22-bad-mixed.t @@ -9,10 +9,22 @@ package main; use strict; use warnings; -use Test::More tests => 3 * 4; +use Test::More tests => 3 * 9; sub meh; +my @warns; + +sub try { + my ($code) = @_; + + @warns = (); + { + local $SIG{__WARN__} = sub { push @warns, @_ }; + eval $code; + } +} + { local $/ = "####"; while () { @@ -26,23 +38,31 @@ sub meh; 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{the code compiled but it shouldn't have\n}; $prefix; no indirect; $_"; - like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"meh"\s+on\s+object\s+"Dongs"\s+at\s+\(eval\s+\d+\)\s+line\s+\d+/, "no indirect, defined: $_"); + skip "$_: $skip" => 9 if eval $skip; + + { + try "return; $prefix; use indirect; $_"; + is $@, '', "use indirect: $_"; + is @warns, 0, 'correct number of reports'; + + try "return; $prefix; no indirect; $_"; + is $@, '', "no indirect: $_"; + is @warns, 0, 'correct number of reports'; + } + + { + local $_ = $_; + s/Hlagh/Dongs/g; + + try "return; $prefix; use indirect; $_"; + is $@, '', "use indirect, defined: $_"; + is @warns, 0, 'correct number of reports'; + + try "return; $prefix; no indirect; $_"; + is $@, '', "use indirect, defined: $_"; + is @warns, 1, 'correct number of reports'; + like $warns[0], qr/^Indirect call of method "meh" on object "Dongs" at \(eval \d+\) line \d+/, 'report 0 is correct'; + } } } }