From: Vincent Pit Date: Wed, 15 Jul 2009 16:59:31 +0000 (+0200) Subject: More freshness for t/21-bad.t X-Git-Tag: v0.17~2 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=94aa495eddd4c48c51cebabae453a4b3ce7c0ab2;p=perl%2Fmodules%2Findirect.git More freshness for t/21-bad.t --- diff --git a/t/21-bad.t b/t/21-bad.t index 11da77d..6852426 100644 --- a/t/21-bad.t +++ b/t/21-bad.t @@ -15,7 +15,7 @@ BEGIN { $reports = 69; } -use Test::More tests => 3 * (4 * $tests + $reports) + 2; +use Test::More tests => 3 * (4 * $tests + $reports) + 4; my ($obj, $x); our ($y, $bloop); @@ -116,11 +116,17 @@ SKIP: } eval { - my $warn; - local $SIG{__WARN__} = sub { $warn = join ' ', @_ }; - eval "die qq{ok\n}; no indirect 'hlagh'; \$obj = new Hlagh1;"; - is($@, "ok\n", 'no indirect "hlagh" didn\'t croak'); - like($warn, qr/^Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"Hlagh1"/, 'no indirect "hlagh" enables the pragma'); + my @warns; + { + local $SIG{__WARN__} = sub { push @warns, @_ }; + eval "return; no indirect 'hlagh'; \$obj = new Hlagh1;"; + } + is $@, '', 'no indirect "hlagh" didn\'t croak'; + is @warns, 1, 'only one warning'; + my $warn = shift @warns; + like $warn, qr/^Indirect call of method "new" on object "Hlagh1"/, + 'no indirect "hlagh" enables the pragma'; + is_deeply \@warns, [ ], 'nothing more'; } __DATA__