Subject: | StrictConstructor + mutable + extends doesn't always dwim |
The attached patch demonstrates the problem. Note that if I make the
new classes in the patch (ExtendsObject, ExtendsStandard) immutable the
new tests do pass. So this is a difference in mutable vs immutable
behavior.
Thanks,
-Todd
Subject: | patch.txt |
diff --git a/t/basic.t b/t/basic.t
index 24f62ce..ec00496 100644
--- a/t/basic.t
+++ b/t/basic.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 15;
+use Test::More tests => 17;
{
@@ -104,6 +104,27 @@ use Test::More tests => 15;
__PACKAGE__->meta()->make_immutable();
}
+{
+ package ExtendsObject;
+
+ use Moose;
+ use MooseX::StrictConstructor;
+ extends 'Moose::Object';
+
+ has 'thing' => ( is => 'rw' );
+ no Moose;
+# __PACKAGE__->meta()->make_immutable();
+}
+
+{
+ package ExtendsStandard;
+
+ use Moose;
+ use MooseX::StrictConstructor;
+ extends 'Standard';
+ no Moose;
+# __PACKAGE__->meta()->make_immutable();
+}
eval { Standard->new( thing => 1, bad => 99 ) };
is( $@, '', 'standard Moose class ignores unknown params' );
@@ -158,3 +179,10 @@ is( $@, '',
eval { ImmutableTricky->new( thing => 1, agent => 99 ) };
like( $@, qr/unknown attribute.+: agent/,
'ImmutableTricky still blows up on unknown params other than spy' );
+
+eval { ExtendsObject->new( thing => 1, bad => 99 ) };
+like( $@, qr/unknown attribute.+: bad/, 'extending Moose::Object can still be strict' );
+
+eval { ExtendsStandard->new( thing => 1, bad => 99 ) };
+like( $@, qr/unknown attribute.+: bad/, 'extending non-strict can still be strict' );
+