X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F022-init-arg.t;h=9546e3dfc42f8c391eedf7493776e7e551b52c44;hb=b6c42ac07e8d9c499b948b0f9015978242550336;hp=aa1bac14aeb04da9fcda0c39c667f61114913ebb;hpb=384072a3e031806229e4b11dfb5c055e8829ff08;p=gitmo%2FMouse.git diff --git a/t/022-init-arg.t b/t/022-init-arg.t index aa1bac1..9546e3d 100644 --- a/t/022-init-arg.t +++ b/t/022-init-arg.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 11; do { package Class; @@ -9,6 +9,7 @@ do { has name => ( is => 'rw', + isa => 'Str', init_arg => 'key', default => 'default', ); @@ -28,3 +29,22 @@ my $attr = $object2->meta->get_attribute('name'); ok($attr, 'got the attribute object by name (not init_arg)'); is($attr->name, 'name', 'name is name'); is($attr->init_arg, 'key', 'init_arg is key'); + +do { + package Foo; + use Mouse; + + has name => ( + is => 'rw', + init_arg => undef, + default => 'default', + ); +}; + +my $foo = Foo->new(name => 'joe'); +is($foo->name, 'default', 'init_arg => undef ignores attribute name in the constructor'); + +Foo->meta->make_immutable; + +my $bar = Foo->new(name => 'joe'); +is($bar->name, 'default', 'init_arg => undef ignores attribute name in the inlined constructor');