X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-StrictConstructor.git;a=blobdiff_plain;f=t%2Fbasic.t;h=d06235f2ce8fa6159ef48b606974d0171b8605eb;hp=d91d3c93d279d68760b81ce4c65be240a5b8b7b0;hb=2ffa7b600545d76ba73216e6f158ea47b984fb3e;hpb=32726d885ed56a2628ec0eccf18b2e898d1ca8ca diff --git a/t/basic.t b/t/basic.t index d91d3c9..d06235f 100644 --- a/t/basic.t +++ b/t/basic.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 6; { @@ -21,6 +21,16 @@ use Test::More tests => 4; } { + package Subclass; + + use MooseX::StrictConstructor; + + extends 'Stricter'; + + has 'size' => ( is => 'rw' ); +} + +{ package Tricky; use MooseX::StrictConstructor; @@ -48,3 +58,9 @@ is( $@, '', 'can work around strict constructor by deleting params in BUILD()' ) eval { Tricky->new( thing => 1, agent => 99 ) }; like( $@, qr/unknown attribute.+: agent/, 'Tricky still blows up on unknown params other than spy' ); + +eval { Subclass->new( thing => 1, bad => 99 ) }; +like( $@, qr/unknown attribute.+: bad/, 'subclass constructor blows up on unknown params' ); + +eval { Subclass->new( thing => 1, size => 'large' ) }; +is( $@, '', 'subclass constructor handles known attributes correctly' );