Subject: | Incorrect documentation for set_list and set_series methods. |
Date: | Tue, 09 May 2017 19:52:33 +0000 (GMT) |
To: | bug-Test-MockObject [...] rt.cpan.org |
From: | Kevin Frost <biztos [...] mac.com> |
Greetings!
I just discovered that the very useful set_list and set_series methods have
incorrect documentation.
Under Mocking we find the following:
* set_list(name, [ item1, item2, ... ]
* set_series(name, [ item1, item2, ... ]
However, both of those methods want regular lists, not arrayrefs. I have
included a demonstration below.
FWIW I would prefer the documented behavior to the actual. :-)
cheers
-- frosty
use strict;
use warnings;
use Data::Dump qw(dump);
use Test::MockObject;
BAD: {
my $series
= Test::MockObject->new->set_series( 'foo', [ 'first', 'second' ] );
print "SERIES\n";
while ( my $val = $series->foo ) {
dump($val);
}
my $list
= Test::MockObject->new->set_list( 'foo', [ 'first', 'second' ] );
print "LIST\n";
for my $val ( $list->foo ) {
dump($val);
}
}
GOOD: {
my $series
= Test::MockObject->new->set_series( 'foo', 'first', 'second' );
print "GOOD SERIES\n";
while ( my $val = $series->foo ) {
dump($val);
}
my $list = Test::MockObject->new->set_list( 'foo', 'first', 'second' );
print "GOOD LIST\n";
for my $val ( $list->foo ) {
dump($val);
}
}
# Output with Test::MockObject VERSION: 1.20161202:
# SERIES
# ["first", "second"]
# LIST
# ["first", "second"]
# GOOD SERIES
# "first"
# "second"
# GOOD LIST
# "first"
# "second"