6 use Test::More tests => 27;
15 Point->meta->add_attribute('x' => (
20 Point->meta->add_attribute('y' => (
27 bless $class->meta->construct_instance(@_) => $class;
39 Point3D->meta->add_attribute('z' => (
46 $self->SUPER::clear();
50 isa_ok(Point->meta, 'Class::MOP::Class');
51 isa_ok(Point3D->meta, 'Class::MOP::Class');
53 # ... test the classes themselves
55 my $point = Point->new('x' => 2, 'y' => 3);
56 isa_ok($point, 'Point');
60 can_ok($point, 'clear');
63 my $meta = $point->meta;
64 is($meta, Point->meta(), '... got the meta from the instance too');
67 is($point->y, 3, '... the y attribute was initialized correctly through the metaobject');
70 is($point->y, 42, '... the y attribute was set properly with the accessor');
72 is($point->x, 2, '... the x attribute was initialized correctly through the metaobject');
76 } '... cannot write to a read-only accessor';
77 is($point->x, 2, '... the x attribute was not altered');
81 is($point->y, 0, '... the y attribute was cleared correctly');
82 is($point->x, 0, '... the x attribute was cleared correctly');
84 my $point3d = Point3D->new('x' => 1, 'y' => 2, 'z' => 3);
85 isa_ok($point3d, 'Point3D');
86 isa_ok($point3d, 'Point');
89 my $meta = $point3d->meta;
90 is($meta, Point3D->meta(), '... got the meta from the instance too');
93 can_ok($point3d, 'x');
94 can_ok($point3d, 'y');
95 can_ok($point3d, 'clear');
97 is($point3d->x, 1, '... the x attribute was initialized correctly through the metaobject');
98 is($point3d->y, 2, '... the y attribute was initialized correctly through the metaobject');
99 is($point3d->{'z'}, 3, '... the z attribute was initialized correctly through the metaobject');
102 my $point3d = Point3D->new();
103 isa_ok($point3d, 'Point3D');
105 is($point3d->x, undef, '... the x attribute was not initialized');
106 is($point3d->y, undef, '... the y attribute was not initialized');
107 is($point3d->{'z'}, 123, '... the z attribute was initialized correctly through the metaobject');