This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bram pointed out the new tests hang if the fix for #72878 isn't in place.
authorAbigail <abigail@abigail.be>
Mon, 22 Feb 2010 14:36:50 +0000 (15:36 +0100)
committerAbigail <abigail@abigail.be>
Mon, 22 Feb 2010 14:39:25 +0000 (15:39 +0100)
This commits traps the recursion and throws an exception.

lib/Tie/Scalar.t

index fb33ca1..a8e803d 100644 (file)
@@ -83,11 +83,22 @@ package main;
 
 @NoMethods::ISA = qw [Tie::Scalar];
 
-eval {tie my $foo => "NoMethods"};
-
-like $@ =>
-    qr /\QNoMethods must define either a TIESCALAR() or a new() method/,
-    "croaks if both new() and TIESCALAR() are missing";
+{
+    #
+    # Without the fix for #72878, the code runs forever.
+    # Trap this, and die if with an appropriate message if this happens.
+    #
+    local $SIG {__WARN__} = sub {
+        die "Called NoMethods->new"
+             if $_ [0] =~ /^WARNING: calling NoMethods->new/;
+    };
+
+    eval {tie my $foo => "NoMethods";};
+
+    like $@ =>
+        qr /\QNoMethods must define either a TIESCALAR() or a new() method/,
+        "croaks if both new() and TIESCALAR() are missing";
+};
 
 #
 # Don't croak on missing new/TIESCALAR if you're inheriting one.