From: Dave Rolsky Date: Thu, 15 Nov 2007 18:37:26 +0000 (+0000) Subject: Add test for immutable class X-Git-Tag: 0.02~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=58812bf9dd6d58f5046d97509b1508ee2fde2e64;p=gitmo%2FMooseX-StrictConstructor.git Add test for immutable class --- diff --git a/t/basic.t b/t/basic.t index d06235f..e65d3f2 100644 --- a/t/basic.t +++ b/t/basic.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 7; { @@ -46,6 +46,17 @@ use Test::More tests => 6; } } +{ + package Immutable; + + use MooseX::StrictConstructor; + + has 'thing' => ( is => 'rw' ); + + no Moose; + __PACKAGE__->meta()->make_immutable(); +} + eval { Standard->new( thing => 1, bad => 99 ) }; is( $@, '', 'standard Moose class ignores unknown params' ); @@ -64,3 +75,7 @@ like( $@, qr/unknown attribute.+: bad/, 'subclass constructor blows up on unknow eval { Subclass->new( thing => 1, size => 'large' ) }; is( $@, '', 'subclass constructor handles known attributes correctly' ); + +eval { Immutable->new( thing => 1, bad => 99 ) }; +like( $@, qr/unknown attribute.+: bad/, + 'strict constructor in immutable class blows up on unknown params' );