6 use Test::More tests => 73;
20 __PACKAGE__->meta->add_attribute('bar');
28 __PACKAGE__->meta->superclasses('Foo');
30 __PACKAGE__->meta->add_attribute('baz');
38 __PACKAGE__->meta->superclasses('Bar');
40 __PACKAGE__->meta->add_attribute('bah');
45 is($meta->name, 'Foo', '... checking the Foo metaclass');
47 ok($meta->is_mutable, '... our class is mutable');
48 ok(!$meta->is_immutable, '... our class is not immutable');
51 $meta->make_immutable();
52 } '... changed Foo to be immutable';
54 ok(!$meta->make_immutable, '... make immutable now returns nothing');
56 ok(!$meta->is_mutable, '... our class is no longer mutable');
57 ok($meta->is_immutable, '... our class is now immutable');
59 isa_ok($meta, 'Class::MOP::Class');
61 dies_ok { $meta->add_method() } '... exception thrown as expected';
62 dies_ok { $meta->alias_method() } '... exception thrown as expected';
63 dies_ok { $meta->remove_method() } '... exception thrown as expected';
65 dies_ok { $meta->add_attribute() } '... exception thrown as expected';
66 dies_ok { $meta->remove_attribute() } '... exception thrown as expected';
68 dies_ok { $meta->add_package_symbol() } '... exception thrown as expected';
69 dies_ok { $meta->remove_package_symbol() } '... exception thrown as expected';
73 @supers = $meta->superclasses;
74 } '... got the superclasses okay';
76 dies_ok { $meta->superclasses([ 'UNIVERSAL' ]) } '... but could not set the superclasses okay';
80 $meta_instance = $meta->get_meta_instance;
81 } '... got the meta instance okay';
82 isa_ok($meta_instance, 'Class::MOP::Instance');
83 is($meta_instance, $meta->get_meta_instance, '... and we know it is cached');
87 @cpl = $meta->class_precedence_list;
88 } '... got the class precedence list okay';
92 '... we just have ourselves in the class precedence list');
96 @attributes = $meta->compute_all_applicable_attributes;
97 } '... got the attribute list okay';
100 [ $meta->get_attribute('bar') ],
101 '... got the right list of attributes');
105 my $meta = Bar->meta;
106 is($meta->name, 'Bar', '... checking the Bar metaclass');
108 ok($meta->is_mutable, '... our class is mutable');
109 ok(!$meta->is_immutable, '... our class is not immutable');
112 $meta->make_immutable();
113 } '... changed Bar to be immutable';
115 ok(!$meta->make_immutable, '... make immutable now returns nothing');
117 ok(!$meta->is_mutable, '... our class is no longer mutable');
118 ok($meta->is_immutable, '... our class is now immutable');
120 isa_ok($meta, 'Class::MOP::Class');
122 dies_ok { $meta->add_method() } '... exception thrown as expected';
123 dies_ok { $meta->alias_method() } '... exception thrown as expected';
124 dies_ok { $meta->remove_method() } '... exception thrown as expected';
126 dies_ok { $meta->add_attribute() } '... exception thrown as expected';
127 dies_ok { $meta->remove_attribute() } '... exception thrown as expected';
129 dies_ok { $meta->add_package_symbol() } '... exception thrown as expected';
130 dies_ok { $meta->remove_package_symbol() } '... exception thrown as expected';
134 @supers = $meta->superclasses;
135 } '... got the superclasses okay';
137 dies_ok { $meta->superclasses([ 'UNIVERSAL' ]) } '... but could not set the superclasses okay';
141 $meta_instance = $meta->get_meta_instance;
142 } '... got the meta instance okay';
143 isa_ok($meta_instance, 'Class::MOP::Instance');
144 is($meta_instance, $meta->get_meta_instance, '... and we know it is cached');
148 @cpl = $meta->class_precedence_list;
149 } '... got the class precedence list okay';
153 '... we just have ourselves in the class precedence list');
157 @attributes = $meta->compute_all_applicable_attributes;
158 } '... got the attribute list okay';
160 [ sort { $a->name cmp $b->name } @attributes ],
161 [ Foo->meta->get_attribute('bar'), $meta->get_attribute('baz') ],
162 '... got the right list of attributes');
166 my $meta = Baz->meta;
167 is($meta->name, 'Baz', '... checking the Baz metaclass');
169 ok($meta->is_mutable, '... our class is mutable');
170 ok(!$meta->is_immutable, '... our class is not immutable');
173 $meta->make_immutable();
174 } '... changed Baz to be immutable';
176 ok(!$meta->make_immutable, '... make immutable now returns nothing');
178 ok(!$meta->is_mutable, '... our class is no longer mutable');
179 ok($meta->is_immutable, '... our class is now immutable');
181 isa_ok($meta, 'Class::MOP::Class');
183 dies_ok { $meta->add_method() } '... exception thrown as expected';
184 dies_ok { $meta->alias_method() } '... exception thrown as expected';
185 dies_ok { $meta->remove_method() } '... exception thrown as expected';
187 dies_ok { $meta->add_attribute() } '... exception thrown as expected';
188 dies_ok { $meta->remove_attribute() } '... exception thrown as expected';
190 dies_ok { $meta->add_package_symbol() } '... exception thrown as expected';
191 dies_ok { $meta->remove_package_symbol() } '... exception thrown as expected';
195 @supers = $meta->superclasses;
196 } '... got the superclasses okay';
198 dies_ok { $meta->superclasses([ 'UNIVERSAL' ]) } '... but could not set the superclasses okay';
202 $meta_instance = $meta->get_meta_instance;
203 } '... got the meta instance okay';
204 isa_ok($meta_instance, 'Class::MOP::Instance');
205 is($meta_instance, $meta->get_meta_instance, '... and we know it is cached');
209 @cpl = $meta->class_precedence_list;
210 } '... got the class precedence list okay';
213 [ 'Baz', 'Bar', 'Foo'],
214 '... we just have ourselves in the class precedence list');
218 @attributes = $meta->compute_all_applicable_attributes;
219 } '... got the attribute list okay';
221 [ sort { $a->name cmp $b->name } @attributes ],
222 [ $meta->get_attribute('bah'), Foo->meta->get_attribute('bar'), Bar->meta->get_attribute('baz') ],
223 '... got the right list of attributes');