Skip Menu |

This queue is for tickets about the Test-MockObject CPAN distribution.

Report information
The Basics
Id: 127539
Status: new
Priority: 0/
Queue: Test-MockObject

People
Owner: Nobody in particular
Requestors: jbruce [...] blosm.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Arg gathering subs should deep copy the args as they are when recorded rather then copying a reference
Date: Wed, 31 Oct 2018 12:57:48 -0500
To: <bug-Test-MockObject [...] rt.cpan.org>
From: <jbruce [...] blosm.com>
I think that args provided to mocked methods should be deep copied to preserve their values at the time. It looks like they are being stored by reference currently. This code illustrates the issue: my $mock = Test::MockObject->new(); $mock->mock('foo', sub{}); My $i = 1; my %args = ( trackey_thing => 1 ); my $obj = { fake_thing => $mock }; while($i < 5){ $obj->{fake_thing}->foo(\%args); $args{trackey_thing}++; $i++; } my ($first_call, $first_args) = $mock->next_call(); print $first_args->[1]->{trackey_thing}; // prints 5 because that is the value of the last iteration John Bruce Senior Software Engineer <http://blosm.com/> b <http://blosm.com/> l <http://blosm.com/> osm.com 424.888.4BEE