Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Deep CPAN distribution.

Report information
The Basics
Id: 26115
Status: resolved
Priority: 0/
Queue: Test-Deep

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

Bug Information
Severity: Critical
Broken in: 0.096
Fixed in: (no value)



Subject: Test::Deep breaks ->isa()
Test::Deep causes main->isa('Foo') to return true. The attached script produces the following output: 1..2 ok 1 - 'main' is not a 'Foo' before using Test::Deep not ok 2 - 'main' should not be a 'Foo' after using Test::Deep # Failed test ''main' should not be a 'Foo' after using Test::Deep' # at ./bug.pl line 14. # 'main->isa('Foo')' yields: Test::Deep::Isa=HASH(0x10194378) # Looks like you failed 1 test of 2. This problem was identified in: http://www.cpanforum.com/threads/4765
Subject: test_deep_isa_bug.pl
#!/usr/bin/perl use strict; use warnings; use Test::More tests => 2; BEGIN { ok(! main->isa('Foo'), q/'main' is not a 'Foo' before using Test::Deep/); } use Test::Deep; ok(! main->isa('Foo'), q/'main' should not be a 'Foo' after using Test::Deep/); diag("'main->isa('Foo')' yields: " . main->isa('Foo')); # EOF
Yes, this is unfortunate, although why anyone would be calling ->isa on main I don't know. It's easy to work around this by doing use Test::Deep (); or use Test::Deep qw( only the functions I want ); both of these will prevent &isa being poked into your namespace. Removing &isa from the default export list is not an option as it would break existing code. I'll add a note in the docs next time I do a release.
From: JDHEDDEN [...] cpan.org
Show quoted text
> Yes, this is unfortunate, although why anyone would be > calling ->isa on main I don't know.
The conflict occurs with Devel::StackTrace which does some tests on all the levels of the caller() stack - main being the last one. (It occurs at line 61 in StackTrace.pm if you're interested.)
Subject: Re: [rt.cpan.org #26115] Test::Deep breaks ->isa()
Date: Thu, 5 Apr 2007 16:22:19 +0100
To: bug-Test-Deep [...] rt.cpan.org
From: "Fergal Daly" <fergal [...] esatclear.ie>
That's intersting. I'd call that a questionable practice but then again, it's useful and there's no alternative to doing it either.
From: JDHEDDEN [...] cpan.org
On Thu Apr 05 11:22:48 2007, fergal@esatclear.ie wrote: Show quoted text
> That's intersting. I'd call that a questionable practice but then > again, it's useful and there's no alternative to doing it either.
Out of curiosity, why is it that your code breaks ->isa, and why can't you 'fix' it?
Subject: Re: [rt.cpan.org #26115] Test::Deep breaks ->isa()
Date: Fri, 6 Apr 2007 09:15:28 +0100
To: bug-Test-Deep [...] rt.cpan.org
From: "Fergal Daly" <fergal [...] esatclear.ie>
My code doesn't "break" isa. When you define an isa subroutine in a class, it has a special meaning but I'm not defining it in a class, I'm just defining it in a normal package where it should be called as a function, not as a method, this is perfectly valid perl. The same goes for can() and does() subroutines. They only have a special with relation to classes. The problem is that Devel::StackTrace calls ->isa() on _all_ of the packages it sees in the stack, whether they're classes or not (a more fundamental problem with Perl is that there's no way to tell). The reason I won't change Test::Deep is because the existing users of Test::Deep have written their tests expecting it to export isa. If it stopped, these test scripts would break and modules authors would receive bug reports and have to make new releases etc etc. I will however file a bug against Devel::StackTrace and see if we can work out something better than calling ->isa on everything it sees.
Couldn't work something out with Devel::Stacktrace but I can't changeTest::Deep either so I'm closing this.
As of 0.103 (just released), isa() will behave as UNIVERSAL::isa() when called with 2 arguments and as regular Test::Deep::isa when called with 1. It's somewhat ugly but should clear up this problem without breaking old code.
jusr resolving this
From: icestar [...] inbox.ru
On Thu Mar 05 17:59:30 2009, FDALY wrote: Show quoted text
> jusr resolving this
Hello. I've got a lot of warnings from UNIVERSAL::isa module like: "Called UNIVERSAL::isa() as a function, not a method" They go from Devel::StackTrace module. Maybe you should not export and override the isa method in the main package by default? One day you should decide to remove deprecated code.
I suspect this may be fixed now, with the recentish changes to how isa() is handled?
On Thu Sep 09 09:27:48 2010, Alien wrote: Show quoted text
> On Thu Mar 05 17:59:30 2009, FDALY wrote:
> > jusr resolving this
> > Hello. > I've got a lot of warnings from UNIVERSAL::isa module like: > "Called UNIVERSAL::isa() as a function, not a method" > They go from Devel::StackTrace module. > Maybe you should not export and override the isa method in the main > package by default? One day you should decide to remove deprecated code.
UNIVERSAL::isa’s warnings are more often than not false positives.
Right now, the code does: goto &UNIVERSAL::isa; I don't mind replacing it with (shift)->isa(@_) or something in the future, if any real problem is found. In general, though, I don't think there is an actual bug, other than "somebody used the UNIVERSAL::isa library." I will be providing an export set without "isa" sometime soon. -- rjbs