[Catalyst] [OT] Universal::CAN warning from TT?
Daniel McBrearty
danielmcbrearty at gmail.com
Thu Nov 23 03:43:33 GMT 2006
thanks - I'll try this when I get a chance and see.
On 11/22/06, Jonathan Rockway <jon at jrock.us> 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 at 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
More information about the Catalyst
mailing list