Require Test::More 0.88 +
[gitmo/MooseX-StrictConstructor.git] / t / basic.t
index 6189cda..5252dc9 100644 (file)
--- a/t/basic.t
+++ b/t/basic.t
@@ -3,7 +3,7 @@ use warnings;
 
 use Test::Fatal;
 use Test::Moose qw( with_immutable );
-use Test::More;
+use Test::More 0.88;
 
 {
     package Standard;
@@ -34,6 +34,27 @@ use Test::More;
 }
 
 {
+    package StrictSubclass;
+
+    use Moose;
+
+    extends 'Stricter';
+
+    has 'size' => ( is => 'rw' );
+}
+
+{
+    package OtherStrictSubclass;
+
+    use Moose;
+    use MooseX::StrictConstructor;
+
+    extends 'Standard';
+
+    has 'size' => ( is => 'rw' );
+}
+
+{
     package Tricky;
 
     use Moose;
@@ -59,7 +80,8 @@ use Test::More;
     has 'size'  => ( is => 'rw', 'init_arg' => undef );
 }
 
-my @classes = qw( Standard Stricter Subclass Tricky InitArg );
+my @classes
+    = qw( Standard Stricter Subclass StrictSubclass OtherStrictSubclass Tricky InitArg );
 
 with_immutable {
     is(
@@ -85,6 +107,30 @@ with_immutable {
     );
 
     is(
+        exception { StrictSubclass->new( thing => 1, size => 'large', ) },
+        undef,
+        q{subclass that doesn't use strict constructor handles known attributes correctly}
+    );
+
+    like(
+        exception { StrictSubclass->new( thing => 1, bad => 99 ) },
+        qr/unknown attribute.+: bad/,
+        q{subclass that doesn't use strict correctly recognizes bad attribute}
+    );
+
+    is(
+        exception { OtherStrictSubclass->new( thing => 1, size => 'large', ) },
+        undef,
+        q{strict subclass from parent that doesn't use strict constructor handles known attributes correctly}
+    );
+
+    like(
+        exception { OtherStrictSubclass->new( thing => 1, bad => 99 ) },
+        qr/unknown attribute.+: bad/,
+        q{strict subclass from parent that doesn't use strict correctly recognizes bad attribute}
+    );
+
+    is(
         exception { Tricky->new( thing => 1, spy => 99 ) }, undef,
         'can work around strict constructor by deleting params in BUILD()'
     );
@@ -96,12 +142,6 @@ with_immutable {
     );
 
     like(
-        exception { Subclass->new( thing => 1, bad => 99 ) },
-        qr/unknown attribute.+: bad/,
-        'subclass constructor blows up on unknown params'
-    );
-
-    like(
         exception { InitArg->new( thing => 1 ) },
         qr/unknown attribute.+: thing/,
         'InitArg blows up with attribute name'