Subject: | [Patch] set_isa does not return the mock object |
The fact that alone of the mockery configuration methods, set_isa does
not return the mock object has surprised me a few times. Since its
return value currently has no defined meaning and since I think it would
make my code marginally prettier, I think it would be correct behavior
for it to do so. The attached patch makes this happen.
Subject: | TMOE-set_isa.diff |
diff -ruN Test-MockObject-1.09/lib/Test/MockObject.pm Test-MockObject-new/lib/Test/MockObject.pm
--- Test-MockObject-1.09/lib/Test/MockObject.pm 2008-05-26 23:16:32.000000000 -0700
+++ Test-MockObject-new/lib/Test/MockObject.pm 2011-01-14 00:44:15.000000000 -0800
@@ -39,6 +39,8 @@
my ($self, @supers) = @_;
my $supers = _isas( $self );
$supers->{$_} = 1 for @supers;
+
+ $self;
}
sub set_always
diff -ruN Test-MockObject-1.09/t/isa.t Test-MockObject-new/t/isa.t
--- Test-MockObject-1.09/t/isa.t 2008-05-26 23:16:32.000000000 -0700
+++ Test-MockObject-new/t/isa.t 2011-01-14 00:39:05.000000000 -0800
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 7;
+use Test::More tests => 8;
use_ok( 'Test::MockObject' );
my $mock = Test::MockObject->new();
@@ -25,3 +25,7 @@
# ... or reporting true for everything
ok( ! $mock->isa( 'Fail' ), '... this is not a "Fail" object' );
+
+# ... and should return itself
+is( $mock->set_isa( 'AnotherParent' ), $mock );
+