thanks - I'll try this when I get a chance and see.

On 11/22/06, Jonathan Rockway <[EMAIL PROTECTED]> wrote:
Daniel McBrearty wrote:
> Just an annoyance, but I'd like to lose it.

Yes, Test::MockObject loads a special UNIVERSAL::can that warns you when
you use UNIVERSAL::can incorrectly.  The problem with calling
UNIVERSAL::can like:

    UNIVERSAL::can($something, 'method')

is that $something doesn't have a chance to override the 'can' that it
inherits from UNIVERSAL.  This obviously breaks Test::MockObject, since
instances are Mock Objects and not real ones (method calls are faked
with AUTOLOAD, which UNIVERSAL::can doesn't know how to deal with).

Here's a rough equivalent:

    package A;
     sub foo { ... }
    package C;
     sub new { bless {} => 'C' }
     our @ISA = 'A';
    package main;
     my $bar = C->new;
     C::foo($bar);

You would never call a class method directly like that (because it won't
work), so you shouldn't do that with UNIVERSAL::can or UNIVERSAL::isa.

I don't see this with my version of TT, though.  If you're using the
latest version, change

    UNIVERSAL::can($object, 'method')

to

    blessed $object && $object->can('method')

and send in a patch.  Much cleaner.

--
package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/



--
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to