X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fbasic.t;h=04046d10cdae5d94f0192fff01252fdb64a4cae0;hb=1ac1adaa4eff9e2237bd50af383b7d93aa1bcabf;hp=1738d92725143eaa434735cf5f183d3059640207;hpb=23cfbce9adb92973d8dc954cb6486be73ed1845e;p=gitmo%2FMooseX-StrictConstructor.git diff --git a/t/basic.t b/t/basic.t index 1738d92..04046d1 100644 --- a/t/basic.t +++ b/t/basic.t @@ -44,6 +44,17 @@ use Test::More; } { + package OtherStrictSubclass; + + use Moose; + use MooseX::StrictConstructor; + + extends 'Standard'; + + has 'size' => ( is => 'rw' ); +} + +{ package Tricky; use Moose; @@ -69,7 +80,7 @@ use Test::More; has 'size' => ( is => 'rw', 'init_arg' => undef ); } -my @classes = qw( Standard Stricter Subclass StrictSubclass Tricky InitArg ); +my @classes = qw( Standard Stricter Subclass StrictSubclass OtherStrictSubclass Tricky InitArg ); with_immutable { is( @@ -106,6 +117,17 @@ with_immutable { ); is( + exception { OtherStrictSubclass->new( thing => 1, size => 'large', ) }, undef, + '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/, + '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()' );