4 use Test::More tests => 11;
18 my $object = Class->new;
19 is($object->name, 'default', 'accessor uses attribute name');
20 is($object->{key}, undef, 'nothing in object->{init_arg}!');
21 is($object->{name}, 'default', 'value is in object->{name}');
23 my $object2 = Class->new(name => 'name', key => 'key');
24 is($object2->name, 'key', 'attribute value is from name');
25 is($object2->{key}, undef, 'no value for the init_arg');
26 is($object2->{name}, 'key', 'value is in key from name');
28 my $attr = $object2->meta->get_attribute('name');
29 ok($attr, 'got the attribute object by name (not init_arg)');
30 is($attr->name, 'name', 'name is name');
31 is($attr->init_arg, 'key', 'init_arg is key');
44 my $foo = Foo->new(name => 'joe');
45 is($foo->name, 'default', 'init_arg => undef ignores attribute name in the constructor');
47 Foo->meta->make_immutable;
49 my $bar = Foo->new(name => 'joe');
50 is($bar->name, 'default', 'init_arg => undef ignores attribute name in the inlined constructor');