public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
use Test::More;
use Test::Mock::Guard qw(mock_guard);
 
{
package Some::Class;
 
sub new { bless {} => shift }
sub foo { "foo" }
};
 
my $o = Some::Class->new;
 
is $o->foo, 'foo';
 
{
my $g1 = mock_guard('Some::Class' => +{ foo => sub { 'xxx' } });
is $o->foo, 'xxx';
 
my $g2 = mock_guard('Some::Class' => +{ foo => sub { 'yyy' } });
is $o->foo, 'yyy';
 
undef $g2;
};
 
is $o->foo, 'foo';
 
done_testing;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.