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