in reply to Re: ISA but no farther?
in thread ISA but no farther?

If I give you a Test::MockObject that can do everything an OP object can but isn't actually blessed into the OP class, you'll think you don't have an OP object if you use ref($obj) eq 'OP. The point is that I want to rule out things that say they are subclasses of OP but not things that would like to think that they are really, truely, an OP object.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^3: ISA but no farther?
by ysth (Canon) on Jul 20, 2006 at 17:00 UTC
    Sorry, missed that part; then you need to fix Test::MockObject to allow something like
    ref($obj) eq 'OP' || ref($obj) eq 'Test::MockObject' && $obj->mocks('O +P')

      That's nasty. I'd just be requiring that objects be always mocked through Test::MockObject instead of some other kind of proxy or whatever.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

        As a variation on ysth's suggestion, you could require that the mocking class implement the 'mocks' method:

        ref($obj) eq 'OP' || $obj->can('mocks') && $obj->mocks('OP')

        Of course, if 'mocks' it handled through AUTOLOAD, this will fail.