From: Vincent Pit Date: Mon, 8 Dec 2008 13:26:20 +0000 (+0100) Subject: Better handling of extraneous warnings in t/30-scope.t X-Git-Tag: v0.09_01~1 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=commitdiff_plain;h=6c5e0c9599d21127c3b91da9f46f3eedcf3f85d2 Better handling of extraneous warnings in t/30-scope.t --- diff --git a/t/30-scope.t b/t/30-scope.t index f358689..20eeebb 100644 --- a/t/30-scope.t +++ b/t/30-scope.t @@ -17,20 +17,19 @@ sub expect { { my $code = do { local $/; }; - my @warns; + my (%res, @left); { - local $SIG{__WARN__} = sub { push @warns, join '', 'warn:', @_ }; + local $SIG{__WARN__} = sub { + my $w = join '', 'warn:', @_; + if ($w =~ /"P(\d+)"/ and not exists $res{$1}) { + $res{$1} = $w; + } else { + push @left, $w; + } + }; eval "die qq{ok\\n}; $code"; is($@, "ok\n", 'DATA compiled fine'); } - my $left = 0; - my %res = map { - if (/"P(\d+)"/) { - $1 => $_ - } else { - ++$left; () - } - } @warns; for (1 .. $tests) { my $w = $res{$_}; if ($wrong{$_}) { @@ -39,7 +38,8 @@ sub expect { is($w, undef, "$_ shouldn't warn"); } } - is($left, 0, 'nothing left'); + is(@left, 0, 'nothing left'); + diag "Extraneous warnings:\n", @left if @left; } {