From: Shawn M Moore Date: Fri, 13 Jun 2008 01:53:36 +0000 (+0000) Subject: Add test for undef init_arg X-Git-Tag: 0.04~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1f679986b3a35589752bf63107265b455605bc45;p=gitmo%2FMouse.git Add test for undef init_arg --- diff --git a/t/022-init-arg.t b/t/022-init-arg.t index aa1bac1..07c221d 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 => 10; do { package Class; @@ -28,3 +28,18 @@ 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'); +