X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fbasic.t;fp=t%2Fbasic.t;h=65aef05e4dc30f7484642375ffeae5c2e5022e2b;hb=a83dec4353207816d24e09f0f3a7afc2200369c4;hp=9c26f8de6c5edc846df8bff9075ed71b994648d7;hpb=02f0d8486d0e8848370b0b850f49b5ce945d9edc;p=gitmo%2FMooseX-StrictConstructor.git diff --git a/t/basic.t b/t/basic.t index 9c26f8d..65aef05 100644 --- a/t/basic.t +++ b/t/basic.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 12; { @@ -47,6 +47,15 @@ use Test::More tests => 9; } { + package InitArg; + + use MooseX::StrictConstructor; + + has 'thing' => ( is => 'rw', 'init_arg' => 'other' ); + has 'size' => ( is => 'rw', 'init_arg' => undef ); +} + +{ package Immutable; use MooseX::StrictConstructor; @@ -106,3 +115,15 @@ is( $@, '', eval { ImmutableTricky->new( thing => 1, agent => 99 ) }; like( $@, qr/unknown attribute.+: agent/, 'ImmutableTricky still blows up on unknown params other than spy' ); + +eval { InitArg->new( thing => 1 ) }; +like( $@, qr/unknown attribute.+: thing/, + 'InitArg blows up with attribute name' ); + +eval { InitArg->new( size => 1 ) }; +like( $@, qr/unknown attribute.+: size/, + 'InitArg blows up when given attribute with undef init_arg' ); + +eval { InitArg->new( other => 1 ) }; +is( $@, '', + 'InitArg works when given proper init_arg' );