summaryrefslogtreecommitdiff
path: root/t/test.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-03-05 11:04:44 +0000
committerNicholas Clark <nick@ccl4.org>2011-03-05 20:26:10 +0000
commit96980024b32bc912ece29c8bb2f36420dce8d27c (patch)
tree72aa775984dd2d12b53155e79ad2eefed20ecdec /t/test.pl
parentc11a8df30b4de6dbf6ce9fa1be2bf37869beb97d (diff)
downloadperl-96980024b32bc912ece29c8bb2f36420dce8d27c.tar.gz
Improve warning_is() to verify that exactly 0 or 1 warning has been seen.
Diffstat (limited to 't/test.pl')
-rw-r--r--t/test.pl14
1 files changed, 11 insertions, 3 deletions
diff --git a/t/test.pl b/t/test.pl
index c895d2acfc..a3bab738d7 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -1065,14 +1065,22 @@ WHOA
sub warning_is {
my ($code, $expect, $name) = @_;
- my $w;
- local $SIG {__WARN__} = sub {$w .= join "" => @_};
+ my @w;
+ local $SIG {__WARN__} = sub {push @w, join "", @_};
{
use warnings 'all';
&$code;
}
local $Level = $Level + 1;
- is($w, $expect, $name);
+ if(!defined $expect) {
+ is("@w", '', $name);
+ } elsif (@w == 1) {
+ is($w[0], $expect, $name);
+ } else {
+ # This will fail, generating diagnostics
+ cmp_ok(scalar @w, '==', 1, $name);
+ diag("Warning: $_") foreach @w;
+ }
}
# Set a watchdog to timeout the entire test file