Created
September 1, 2011 10:42
-
-
Save cho45/1185921 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment