I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2008-10-02 20:15:43-07 by pault
OIO incompatible with Test::MockObject

Hello,

I guess not many people use both Test::MockObject and Object::InsideOut otherwise this problem would have been discussed before. And I guess the reason, is that Test::MockObject, without a tiny bit of tweaking, mocks only hash-based objects and not inside-out ones.

Never the less, if you have a project, especially a legacy project, that uses Object::InsideOut for some objects, but whose test suite uses Test::MockObject then you have a problem. The problem arises because Test::MockObject uses UNIVERSAL::can which includes a warning when &UNIVERSAL::can is called as a subroutine rather than a method.

OIO takes a reference to &UNIVERSAL::can and calls the reference at line 29 of Object::InsideOut::Universal. This results in an annoying warning. The warning is correct, because UNIVERSAL::can is a method, not a function and calling this coderef is a bug.

In a discussion on use.perl (http://use.perl.org/~TheNomad/journal/37579), chromatic suggests that a fix would be for OIO to subclass UNIVERSAL, say OIOUniversal, that can then call the superclass method when necessary without actually trying to rewrite &UNIVERSAL::can.

It appears to me this would work. Has anyone got any thoughts?

Direct Responses: 8930 | 8943 | Write a response
Posted on 2008-10-03 12:39:49-07 by jdhedden in response to 8923
Re: OIO incompatible with Test::MockObject
Sub-classing UNIVERSAL sounds like something reasonable to investigate. I'll look into it in a few days. Thanks for bringing this to my attention.
Direct Responses: Write a response
Posted on 2008-10-03 20:24:58-07 by jdhedden in response to 8923
Re: OIO incompatible with Test::MockObject
I've uploaded a new version of OIO (3.46) to CPAN that addresses this issue. I've taken the tact of using 'no warnings;' before calling the UNIVERSAL::can() subroutine. While I'm sure that some purists would not approve, it is a practical and efficient solution, and should be quite safe.

If this doesn't work for you, let me know with some details so I can deal with it further.

Thanks for using OIO.
Direct Responses: 8969 | Write a response
Posted on 2008-10-06 11:37:37-07 by pault in response to 8943
Re: OIO incompatible with Test::MockObject

Thanks for sorting out the issue of the warnings so promptly. Certainly, upgrading to v. 3.46 stops the warnings. This deals with the immediate annoyance.

However, it doesn't deal with the main issue which is whether OIO should be rewriting &UNIVERSAL::can and &UNIVERSAL::isa, which can make O:IO incompatible with portions of an application that do no use O:IO to create classes.

Thanks

Direct Responses: 8973 | Write a response
Posted on 2008-10-06 13:08:20-07 by jdhedden in response to 8969
Re: OIO incompatible with Test::MockObject
In what way is OIO "incompatible with portions of an application that do no use O:IO to create classes"? I would be extremely grateful if you could supply me with an example so that I could fix any such incompatibility. Thanks.
Direct Responses: 8976 | Write a response
Posted on 2008-10-06 18:05:29-07 by jdhedden in response to 8973
Re: OIO incompatible with Test::MockObject
I have seen the error of my ways, and have just uploaded OIO 3.47 to CPAN which has a "proper" implementation for ->can() and ->isa() that does not rely on cached pointers to UNIVERSAL::can() and UNIVERSAL::isa(). Hopefully, this version will also meet with your needs, as well as with your approval.

Thanks for prodding me to delve into this issue. And thanks again for using OIO.
Direct Responses: 9031 | Write a response
Posted on 2008-10-12 19:50:01-07 by pault in response to 8976
Re: OIO incompatible with Test::MockObject
Looks good thanks!
Direct Responses: Write a response