Problems? Is your data what you think it is? | |
PerlMonks |
Test::MockObject doesn't fool UNIVERSALby water (Deacon) |
on Jul 10, 2005 at 21:56 UTC ( [id://473797]=perlquestion: print w/replies, xml ) | Need Help?? |
water has asked for the wisdom of the Perl Monks concerning the following question:
Perhaps I'm wanting too much, but I think I'm seeing
that an object mocked by Test::MockObject doesn't fool UNIVERSAL::isa and UNIVERSAL::can.
Here's some code giving the idea:
Is this because UNIVERSAL is the root of the object hierarchy, and thus can't be fooled? If so, it would seem that methods which need to check the type of their arguments (asserting if the wrong param type sent, for example), should use $self->isa rather than UNIVERSAL::isa to do so, as otherwise you can't use Mock Objects to test the methods. (In contrast, this nice perl OO style guide suggests UNIVERSAL:: over the method call approach. Which I think isn't great advice if you'll be testing with Test::MockObject.) This isn't a SOPW post per se, but I end with the following question: are the observations above correct, or did I misuse UNIVERSAL? Thanks! Retitled by davido from 'Class::MockObject doesn't fool UNIVERSAL'.
Back to
Seekers of Perl Wisdom
|
|