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: 30394
Status: resolved
Priority: 0/
Queue: Test-Deep

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

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Should not directly call UNIVERSAL::isa and ::can
Test::Deep currently calls UNIVERSAL::isa and UNIVERSAL::can to figure out what an object is or can do. As perlobj(1) points out, this prevents classes from overriding these methods. (Overriding can() would allow me to overcome the current AUTOLOAD bug.)
On Wed Oct 31 16:59:55 2007, FBRIERE wrote: Show quoted text
> Test::Deep currently calls UNIVERSAL::isa and UNIVERSAL::can to figure > out what an object is or can do. As perlobj(1) points out, this > prevents classes from overriding these methods. (Overriding can() would > allow me to overcome the current AUTOLOAD bug.)
Here's a patch that I think fixes it. If Fergal wants to use it I'll provide some test coverage too.
diff -uNr Test-Deep.orig/lib/Test/Deep/Isa.pm Test-Deep/lib/Test/Deep/Isa.pm --- Test-Deep.orig/lib/Test/Deep/Isa.pm 2005-11-30 14:09:32.000000000 +0000 +++ Test-Deep/lib/Test/Deep/Isa.pm 2008-06-21 16:12:25.000000000 +0100 @@ -18,7 +18,9 @@ my $self = shift; my $got = shift; - return UNIVERSAL::isa($got, $self->{val}); + return ( UNIVERSAL::can( $got, 'isa' ) + && $got->isa( $self->{val} ) ) + || UNIVERSAL::isa( $got, $self->{val} ); } sub diag_message diff -uNr Test-Deep.orig/lib/Test/Deep/Methods.pm Test-Deep/lib/Test/Deep/Methods.pm --- Test-Deep.orig/lib/Test/Deep/Methods.pm 2005-11-30 14:09:32.000000000 +0000 +++ Test-Deep/lib/Test/Deep/Methods.pm 2008-06-21 16:11:00.000000000 +0100 @@ -39,7 +39,8 @@ my ($call, $exp_res) = @$method; my ($name) = @$call; - my $got_res = UNIVERSAL::can($got, $name) ? + my $got_res = UNIVERSAL::can($got, 'can') + && $got->can($name) ? $self->call_method($got, $call) : $Test::Deep::DNE;
On Sat Jun 21 13:53:29 2008, ANDYA wrote: Show quoted text
> On Wed Oct 31 16:59:55 2007, FBRIERE wrote:
> > Test::Deep currently calls UNIVERSAL::isa and UNIVERSAL::can to
> figure
> > out what an object is or can do. As perlobj(1) points out, this > > prevents classes from overriding these methods. (Overriding can()
> would
> > allow me to overcome the current AUTOLOAD bug.)
> > Here's a patch that I think fixes it. If Fergal wants to use it I'll > provide some test coverage too.
I though I had replied to this but I don't see it anywhere. I'm not a fan of changing behaviour so what I'd like to do is leave the current behaviour as is and make it clear that it uses UNIVERSAL and then add some appropriately named others that use ->isa and ->can. I looked at the patch. I would have tested for blessedness and then called can or isa. What's the reason for doing it as you've done? F
This has been fixed by independent work. -- rjbs