Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Params::Validate and Test::MockObject::Extends

by chromatic (Archbishop)
on May 09, 2006 at 07:47 UTC ( #548157=note: print w/replies, xml ) Need Help??

in reply to Params::Validate and Test::MockObject::Extends

Params::Validate is broken. (I read its code; both the pure Perl and XS code have the same bug.) It thinks that UNIVERSAL::isa is a function. (It's not. It's a method.)

Which version of Test::MockObject::Extends are you using? Newer versions use UNIVERSAL::isa which tries to work around this problem and attempts to reveal which code is broken, buggy, and wrong.

(Of course, if you're using the XS version of Params::Validate, you'll never see the error message because UNIVERSAL::isa doesn't have hooks that deep.)

Replies are listed 'Best First'.
Re^2: Params::Validate and Test::MockObject::Extends
by diotalevi (Canon) on May 09, 2006 at 13:10 UTC

    There's an option you can set to force the use of the pure perl, non-XS Params::Validate. It sounds like the easiest thing to do is force plain perl Params::Validate and then use UNIVERSAL::isa.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re^2: Params::Validate and Test::MockObject::Extends
by badaiaqrandista (Pilgrim) on May 09, 2006 at 12:18 UTC

    I use Test::MockObject::Extends version 0.20 and Params::Validate version 0.76, both of them come with debian stable.

    Anyway, I have found a workaround. I have changed the test script like this:

    #!/usr/bin/perl use strict; use warnings; use Test::MockObject; my $mock = Test::MockObject->new; $mock->fake_module( 'MyApp::Property', new => sub { bless {}, 'MyApp::Property' }, id => sub { 1 }, su_pwd => sub { 'password' } ); my $mock_property = MyApp::Property->new; my $admin = MyApp::Admin->new(owner => $mock_property, id => 0); is_deeply( $admin, { admin_id => 0, domain_id => '1', firstname => 'Super', lastname => 'User', username => 'su', password => 'password', }, "new() with id eq '0' (superuser)" );
Re^2: Params::Validate and Test::MockObject::Extends
by autarch (Hermit) on May 09, 2006 at 21:38 UTC

    Gee, thanks for the bug report. Oh, you didn't bother sending one!

    The XS version actually uses the Perl API's sv_derived_from() function, which apparently is like calling UNIVERSAL::isa(). You might want to submit a doc patch for the Perl core warning people off from using it if you really want to promote "proper" use of isa() and can().

      Sorry, I've never filed a bug report before. And I thought it was my fault. Anyway, what do you mean by 'proper' use of isa() and can()?


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://548157]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2019-09-18 17:34 GMT
Find Nodes?
    Voting Booth?
    The room is dark, and your next move is ...

    Results (235 votes). Check out past polls.