This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid obscure failures when a regexp hasn't matched
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 6 Feb 2007 22:29:45 +0000 (22:29 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 6 Feb 2007 22:29:45 +0000 (22:29 +0000)
p4raw-id: //depot/perl@30149

t/op/bless.t

index 6aea7ba..d5ae885 100644 (file)
@@ -14,10 +14,14 @@ sub expected {
     is(ref($object), $package);
     my $r = qr/^\Q$package\E=(\w+)\(0x([0-9a-f]+)\)$/;
     like("$object", $r);
-    "$object" =~ $r;
-    is($1, $type);
-    # in 64-bit platforms hex warns for 32+ -bit values
-    cmp_ok(do {no warnings 'portable'; hex($2)}, '==', $object);
+    if ("$object" =~ $r) {
+       is($1, $type);
+       # in 64-bit platforms hex warns for 32+ -bit values
+       cmp_ok(do {no warnings 'portable'; hex($2)}, '==', $object);
+    }
+    else {
+       fail(); fail();
+    }
 }
 
 # test blessing simple types