4 use Test::More tests => 36;
26 my $object = Class->new;
27 is($object->x, 10, "attribute has a default of 10");
28 is($object->y, 20, "attribute has a default of 20");
29 is($object->z, undef, "attribute has no default");
31 is($object->x(5), 5, "setting a new value");
32 is($object->y(25), 25, "setting a new value");
33 is($object->z(125), 125, "setting a new value");
35 is($object->x, 5, "setting a new value does not trigger default");
36 is($object->y, 25, "setting a new value does not trigger default");
37 is($object->z, 125, "setting a new value does not trigger default");
39 my $object2 = Class->new(x => 50);
40 is($object2->x, 50, "attribute was initialized to 50");
41 is($object2->y, 20, "attribute has a default of 20");
42 is($object2->z, undef, "attribute has no default");
44 is($object2->x(5), 5, "setting a new value");
45 is($object2->y(25), 25, "setting a new value");
46 is($object2->z(125), 125, "setting a new value");
48 is($object2->x, 5, "setting a new value does not trigger default");
49 is($object2->y, 25, "setting a new value does not trigger default");
50 is($object2->z, 125, "setting a new value does not trigger default");
52 Class->meta->make_immutable;