Skip Menu |
 

This queue is for tickets about the Scalar-List-Utils CPAN distribution.

Report information
The Basics
Id: 76171
Status: resolved
Priority: 0/
Queue: Scalar-List-Utils

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 1.24
  • 1.25
Fixed in: 1.28

Attachments
0001-Fix-the-tests-for-blessed-so-they-don-t-break-Test-M.patch



Subject: Fix blessed.t for Test::Builder2
Download (untitled) / with headers
text/plain 263b
t/blessed.t breaks UNIVERSAL::can. This will break future versions of Test::More whose test versions will rely on can() and it's probably a bad idea in general. The attached patch moves the UNIVERSAL::can bits into its own file which doesn't use a test library.
Subject: 0001-Fix-the-tests-for-blessed-so-they-don-t-break-Test-M.patch
From 34a59e5bf40c0b43cc1f29d7263d27faf06ab1ac Mon Sep 17 00:00:00 2001 From: "Michael G. Schwern" <schwern@pobox.com> Date: Fri, 30 Mar 2012 18:52:36 +0200 Subject: [PATCH] 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. --- t/blessed.t | 12 +----------- t/blessed_UNIVERSAL_can.t | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 t/blessed_UNIVERSAL_can.t diff --git a/t/blessed.t b/t/blessed.t index f0a4c19..1925297 100644 --- a/t/blessed.t +++ b/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 }; diff --git a/t/blessed_UNIVERSAL_can.t b/t/blessed_UNIVERSAL_can.t new file mode 100644 index 0000000..5a58ad3 --- /dev/null +++ b/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"; +} -- 1.7.9.4
Subject: Re: [rt.cpan.org #76171] Fix blessed.t for Test::Builder2
Date: Fri, 30 Mar 2012 11:59:43 -0500
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
Download (untitled) / with headers
text/plain 377b
Probably could have been done as { my $blessed = do { my $depth; no warnings 'redefine'; local *UNIVERSAL::can = sub { die "Burp!" if ++$depth > 2; blessed(shift) }; $x = bless {}, "DEF"; blessed($x); } is($blessed, "DEF", 'recursion of UNIVERSAL::can'); } to isolate the change of UNIVERSAL::can and not bread other packages that use it Graham.
Subject: Re: [rt.cpan.org #76171] Fix blessed.t for Test::Builder2
Date: Fri, 30 Mar 2012 19:38:36 +0200
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
Download (untitled) / with headers
text/plain 127b
That's much better! I've changed it to that in my pull request. https://github.com/Scalar-List-Utils/Scalar-List-Utils/pull/2
It looks like this got merged back in April, but isn't yet on CPAN. Poke-poke ;)
Download (untitled) / with headers
text/plain 194b
On Mon Jul 08 02:31:52 2013, RIBASUSHI wrote: Show quoted text
> It looks like this got merged back in April, but isn't yet on CPAN. > Poke-poke ;)
I believe this was released way back in 1.28. -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.