13 Point->meta->add_attribute('x' => (
18 Point->meta->add_attribute('y' => (
25 bless $class->meta->new_object(@_) => $class;
37 Point3D->meta->add_attribute('z' => (
44 $self->SUPER::clear();
48 isa_ok(Point->meta, 'Class::MOP::Class');
49 isa_ok(Point3D->meta, 'Class::MOP::Class');
51 # ... test the classes themselves
53 my $point = Point->new('x' => 2, 'y' => 3);
54 isa_ok($point, 'Point');
58 can_ok($point, 'clear');
61 my $meta = $point->meta;
62 is($meta, Point->meta(), '... got the meta from the instance too');
65 is($point->y, 3, '... the y attribute was initialized correctly through the metaobject');
68 is($point->y, 42, '... the y attribute was set properly with the accessor');
70 is($point->x, 2, '... the x attribute was initialized correctly through the metaobject');
74 }, undef, '... cannot write to a read-only accessor' );
75 is($point->x, 2, '... the x attribute was not altered');
79 is($point->y, 0, '... the y attribute was cleared correctly');
80 is($point->x, 0, '... the x attribute was cleared correctly');
82 my $point3d = Point3D->new('x' => 1, 'y' => 2, 'z' => 3);
83 isa_ok($point3d, 'Point3D');
84 isa_ok($point3d, 'Point');
87 my $meta = $point3d->meta;
88 is($meta, Point3D->meta(), '... got the meta from the instance too');
91 can_ok($point3d, 'x');
92 can_ok($point3d, 'y');
93 can_ok($point3d, 'clear');
95 is($point3d->x, 1, '... the x attribute was initialized correctly through the metaobject');
96 is($point3d->y, 2, '... the y attribute was initialized correctly through the metaobject');
97 is($point3d->{'z'}, 3, '... the z attribute was initialized correctly through the metaobject');
100 my $point3d = Point3D->new();
101 isa_ok($point3d, 'Point3D');
103 is($point3d->x, undef, '... the x attribute was not initialized');
104 is($point3d->y, undef, '... the y attribute was not initialized');
105 is($point3d->{'z'}, 123, '... the z attribute was initialized correctly through the metaobject');