Subject: | Cannot use set_bound to bind to an arrayref |
One cannot use set_bound to bind a method to an arrayref, e.g.
my $mock = Test::MockObject->new();
my $arrayref = [1, 2, 3];
$mock->set_bound('arrayref', \$arrayref);
print Dumper($mock->arrayref);
The object behaves as if 'arrayref' method has not been mocked at all
(see the attachment for the exact source):
Un-mocked method 'arrayref()' called at ./test.pm line 13
The expected result would be:
$VAR1 = [
1,
2,
3
];
The attached one-line patch fixes the bug (set_bound doesn't know what
to do with a reference to a reference).
---
Distribution name and version
Test-MockObject-1.20110612
Perl version
v5.10.1
Operating System vendor and version
Linux aluminium 2.6.38-11-generic-pae #48-Ubuntu SMP Fri Jul 29 20:51:21
UTC 2011 i686 i686 i386 GNU/Linux
Subject: | set_bound_patch |
Message body not shown because it is not plain text.
Subject: | test.pm |
#!/usr/bin/perl
use warnings;
use strict;
use Test::MockObject;
use Data::Dumper;
my $mock = Test::MockObject->new();
my $arrayref = [1, 2, 3];
$mock->set_bound('arrayref', \$arrayref);
print Dumper($mock->arrayref);