Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix the tests for blessed() so they don't break Test::More.

Test::More might need UNIVERSAL::can, which blessed.t breaks.  Move the
bit that breaks UNIVERSAL::can into its own file which doesn't use a
test library.
  • Loading branch information...
commit 34a59e5bf40c0b43cc1f29d7263d27faf06ab1ac 1 parent f16d69a
@schwern authored
Showing with 31 additions and 11 deletions.
  1. +1 −11 t/blessed.t
  2. +30 −0 t/blessed_UNIVERSAL_can.t
View
12 t/blessed.t
@@ -13,7 +13,7 @@ BEGIN {
}
}
-use Test::More tests => 11;
+use Test::More tests => 10;
use Scalar::Util qw(blessed);
use vars qw($t $x);
@@ -34,16 +34,6 @@ $x = bless {}, "0";
cmp_ok(blessed($x), "eq", "0", 'blessed HASH-ref');
{
- my $depth;
- {
- no warnings 'redefine';
- *UNIVERSAL::can = sub { die "Burp!" if ++$depth > 2; blessed(shift) };
- }
- $x = bless {}, "DEF";
- is(blessed($x), "DEF", 'recursion of UNIVERSAL::can');
-}
-
-{
package Broken;
sub isa { die };
sub can { die };
View
30 t/blessed_UNIVERSAL_can.t
@@ -0,0 +1,30 @@
+#!./perl
+
+BEGIN {
+ unless (-d 'blib') {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require Config; import Config;
+ keys %Config; # Silence warning
+ if ($Config{extensions} !~ /\bList\/Util\b/) {
+ print "1..0 # Skip: List::Util was not built\n";
+ exit 0;
+ }
+ }
+}
+
+use Scalar::Util qw(blessed);
+
+# Can't use a test library, we're going to break UNIVERSAL::can
+print "1..1\n";
+{
+ my $depth;
+ {
+ no warnings 'redefine';
+ *UNIVERSAL::can = sub { die "Burp!" if ++$depth > 2; blessed(shift) };
+ }
+
+ my $x = bless {}, "DEF";
+ my $ok = blessed($x) eq "DEF" ? "ok" : "not ok";
+ print "$ok 1 - recursion of UNIVERSAL::can\n";
+}
Please sign in to comment.
Something went wrong with that request. Please try again.