6 use Test::More tests => 32;
19 has '$.x' => (reader => 'x');
20 has '$.y' => (accessor => 'y');
37 after 'clear' => sub {
44 my $point = Point->new(x => 1, y => 2);
45 isa_ok($point, 'Point');
46 isa_ok($point, 'Moose::Object');
48 is($point->x, 1, '... got the right value for x');
49 is($point->y, 2, '... got the right value for y');
52 is($point->y, 10, '... got the right (changed) value for y');
55 is($point->x, 1, '... got the right (un-changed) value for x');
59 is($point->x, 0, '... got the right (cleared) value for x');
60 is($point->y, 0, '... got the right (cleared) value for y');
62 my $point3d = Point3D->new(x => 10, y => 15, z => 3);
63 isa_ok($point3d, 'Point3D');
64 isa_ok($point3d, 'Point');
65 isa_ok($point3d, 'Moose::Object');
67 is($point3d->x, 10, '... got the right value for x');
68 is($point3d->y, 15, '... got the right value for y');
69 is($point3d->{'$:z'}, 3, '... got the right value for z');
73 } '... there is no method for z';
77 is($point3d->x, 0, '... got the right (cleared) value for x');
78 is($point3d->y, 0, '... got the right (cleared) value for y');
79 is($point3d->{'$:z'}, 0, '... got the right (cleared) value for z');
81 # test some class introspection
83 can_ok('Point', 'meta');
84 isa_ok(Point->meta, 'Moose::Meta::Class');
86 can_ok('Point3D', 'meta');
87 isa_ok(Point3D->meta, 'Moose::Meta::Class');
89 isnt(Point->meta, Point3D->meta, '... they are different metaclasses as well');
94 [ Point->meta->superclasses ],
96 '... Point got the automagic base class');
98 my @Point_methods = qw(x y clear);
101 [ sort @Point_methods ],
102 [ sort Point->meta->get_method_list() ],
103 '... we match the method list for Point');
105 foreach my $method (@Point_methods) {
106 ok(Point->meta->has_method($method), '... Point has the method "' . $method . '"');
112 [ Point3D->meta->superclasses ],
114 '... Point3D gets the parent given to it');
116 my @Point3D_methods = qw(clear);
119 [ sort @Point3D_methods ],
120 [ sort Point3D->meta->get_method_list() ],
121 '... we match the method list for Point3D');
123 foreach my $method (@Point3D_methods) {
124 ok(Point3D->meta->has_method($method), '... Point3D has the method "' . $method . '"');