Permalink
Browse files

Merge remote-tracking branch 'origin/master' into feature/support-cla…

…ss-method-mocked
  • Loading branch information...
2 parents 47172fc + 0ad7751 commit 219cd168018a4d2f2c6ebaf38e68f0f2b046b022 @NetPenguin committed Aug 17, 2013
View
@@ -4,6 +4,7 @@
/blib
/carton.lock
+/cpanfile.snapshot
/.carton/
/local/
View
@@ -2,6 +2,8 @@ Revision history for Perl extension Test-EasyMock
{{$NEXT}}
+ * Fix circular reference.
+
0.07 2013-07-05T03:12:05Z
* Use Data::Dump instead of Data::Dumper.
View
@@ -107,7 +107,7 @@ sub create_mock {
return $control->create_mock;
}
-=head2 expect($expectation)
+=head2 expect(<a mock method call>)
Record a method invocation and behavior.
@@ -155,8 +155,7 @@ Set I<die> behavior as as stub to the expectation.
=cut
sub expect {
- my ($expectation) = @_;
- return __delegate(expect => ($expectation->mock, $expectation));
+ return __delegate(expect => @_);
}
=head2 replay($mock [, $mock2 ...])
@@ -8,35 +8,23 @@ Test::EasyMock::Expectation - A expected behavior object.
=cut
use Carp qw(croak);
-use Scalar::Util qw(refaddr);
=head1 CONSTRUCTORS
-=head2 new({mock=>$mock, method=>$method, args=>$args})
+=head2 new(method=>$method, args=>$args})
Create a instance.
=cut
sub new {
my ($class, $args) = @_;
return bless {
- _mock => $args->{mock},
_method => $args->{method},
_args => $args->{args},
_results => [ { code => sub { return; }, implicit => 1 } ],
}, $class;
}
-=head1 PROPERTIES
-
-=head2 mock - A related mock object.
-
-=cut
-sub mock {
- my ($self) = @_;
- return $self->{_mock};
-}
-
=head1 METHODS
=head2 push_result($code)
@@ -112,8 +100,7 @@ It is tested whether the specified argument matches.
=cut
sub matches {
my ($self, $args) = @_;
- return refaddr($self->{_mock}) == refaddr($args->{mock})
- && $self->{_method} eq $args->{method}
+ return $self->{_method} eq $args->{method}
&& $self->{_args}->matches($args->{args});
}
@@ -10,7 +10,7 @@ Test::EasyMock::MockControl - Control behavior of the mock object.
use Data::Dump qw(pp);
use Data::Util qw(is_instance);
use List::Util qw(first);
-use Scalar::Util qw(blessed refaddr);
+use Scalar::Util qw(blessed);
use Test::Builder;
use Test::EasyMock::ArgumentsMatcher;
use Test::EasyMock::Expectation;
@@ -33,7 +33,7 @@ sub create_control {
=head1 CONSTRUCTORS
-=head2 new($expectation)
+=head2 new([$module|$object])
Create a instance.
@@ -110,13 +110,13 @@ Record the method invocation.
=cut
sub record_method_invocation {
my ($self, $mock, $method, @args) = @_;
- return Test::EasyMock::Expectation->new({
- mock => $mock,
+ my $expectation = Test::EasyMock::Expectation->new({
method => $method,
args => is_instance($args[0], 'Test::EasyMock::ArgumentsMatcher')
? $args[0]
: Test::EasyMock::ArgumentsMatcher->new(\@args),
});
+ return ($mock, $expectation);
}
=head2 find_expectation($args)
Oops, something went wrong.

0 comments on commit 219cd16

Please sign in to comment.