summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-03-13 21:30:55 +0000
committerNicholas Clark <nick@ccl4.org>2011-03-13 21:30:55 +0000
commit9eb41b690e9c66416ca5e28fe9acb0f2595cbd3f (patch)
tree4d3f16a26ef0a9d354c3cb96b97c0be6e9fc4669 /t
parentcb79f740dae4d41cfe556ac0e57a6e7afcd0fb6f (diff)
downloadperl-9eb41b690e9c66416ca5e28fe9acb0f2595cbd3f.tar.gz
In test.pl, avoid using a closure to capture warnings.
In the general case a closure is the "right" way to do "it". However, closures, unlike local and regular subroutines, have some complexity at compile time, which means that using closures in test.pl runs the risk of closure bugs causing spurious hard to diagnose collateral damage to other tests. local is already in use, and "has" to work for capturing warnings, as $SIG{__WARN__} is localised already.
Diffstat (limited to 't')
-rw-r--r--t/test.pl11
1 files changed, 8 insertions, 3 deletions
diff --git a/t/test.pl b/t/test.pl
index d83f69bc32..d9b94328f8 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -1097,13 +1097,18 @@ WHOA
_ok( !$diag, _where(), $name );
}
+# Purposefully avoiding a closure.
+sub __capture {
+ push @::__capture, join "", @_;
+}
+
sub capture_warnings {
my $code = shift;
- my @w;
- local $SIG {__WARN__} = sub {push @w, join "", @_};
+ local @::__capture;
+ local $SIG {__WARN__} = \&__capture;
&$code;
- return @w;
+ return @::__capture;
}
# This will generate a variable number of tests.