summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Carp.t15
-rw-r--r--lib/Carp/Heavy.pm1
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/Carp.t b/lib/Carp.t
index e9dd8cd7f5..2ea98d86d7 100644
--- a/lib/Carp.t
+++ b/lib/Carp.t
@@ -5,7 +5,7 @@ BEGIN {
use Carp qw(carp cluck croak confess);
-print "1..8\n";
+print "1..9\n";
print "ok 1\n";
@@ -56,3 +56,16 @@ my $eval = "use Carp::Heavy; return Carp::caller_info(0);";
my %info = eval($eval);
print "not " if ($info{sub_name} ne "eval '$eval'");
print "ok 8\n";
+
+# test for '...::CARP_NOT used only once' warning from Carp::Heavy
+my $warning;
+eval {
+ BEGIN {
+ $^W = 1;
+ $SIG{__WARN__} =
+ sub { if( defined $^S ){ warn $_[0] } else { $warning = $_[0] } }
+ }
+ package Z;
+ BEGIN { eval { Carp::croak() } }
+};
+print $warning ? "not ok 9\n#$warning" : "ok 9\n";
diff --git a/lib/Carp/Heavy.pm b/lib/Carp/Heavy.pm
index cf108923f4..c3d3c26fa1 100644
--- a/lib/Carp/Heavy.pm
+++ b/lib/Carp/Heavy.pm
@@ -237,6 +237,7 @@ sub trusts {
sub trusts_directly {
my $class = shift;
no strict 'refs';
+ no warnings 'once';
return @{"$class\::CARP_NOT"}
? @{"$class\::CARP_NOT"}
: @{"$class\::ISA"};