4 use Test::More tests => 4;
12 has 'thing' => ( is => 'rw' );
18 use MooseX::StrictConstructor;
20 has 'thing' => ( is => 'rw' );
26 use MooseX::StrictConstructor;
28 has 'thing' => ( is => 'rw' );
35 delete $params->{spy};
40 eval { Standard->new( thing => 1, bad => 99 ) };
41 is( $@, '', 'standard Moose class ignores unknown params' );
43 eval { Stricter->new( thing => 1, bad => 99 ) };
44 like( $@, qr/unknown attribute.+: bad/, 'strict constructor blows up on unknown params' );
46 eval { Tricky->new( thing => 1, spy => 99 ) };
47 is( $@, '', 'can work around strict constructor by deleting params in BUILD()' );
49 eval { Tricky->new( thing => 1, agent => 99 ) };
50 like( $@, qr/unknown attribute.+: agent/, 'Tricky still blows up on unknown params other than spy' );