Click here to get back home

MockObject - reference

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
MockObject - reference fbalicki 09-25-2007
Posted by fbalicki on September 25, 2007, 9:03 am
Please log in for more thread options
Welcome!

I need fake object to tests. I tried to use Test::MockObject

Example below show my problem:
Fake object $tmp was created by fake xxx->new, but ref is still
"Test::MockObject" and set_xxx dies during checking reference

Regards,
Filip (Poland)

use Test::MockObject;
use Data::Dumper;

$Mock_ua = Test::MockObject->new;
$Mock_ua->fake_module('xxx');
$Mock_ua->fake_new('xxx');

my $tmp = xxx->new();
my $mytest = mytest->new();

$mytest->set_xxx($tmp);

package mytest;
{

sub new {
my $class = shift;
my $self = {};
bless ($self, $class);
return $self;
}

sub set_xxx {
my $this = shift;
my $foo = shift;
die "Wrong reference" if (ref $foo ne 'xxx');
}
}


Similar ThreadsPosted
Test::MockObject::Extends for windows September 1, 2004, 10:16 am
Win32::Ole and Call by reference October 22, 2004, 10:06 am
Quick Perl, HTML, CSS, JavaScript reference April 26, 2006, 10:34 am
Crypt::CBC Can't call method "blocksize" on unblessed reference July 12, 2004, 10:01 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap