Commit | Line | Data |
55743c1a |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Class::MOP; |
5 | |
6 | use Test::More; |
7 | |
8 | { |
9 | package Foo; |
10 | use metaclass; |
11 | |
12 | Foo->meta->add_attribute( '@foo', accessor => 'foo' ); |
13 | Foo->meta->add_attribute( '!bar', reader => 'bar' ); |
14 | Foo->meta->add_attribute( '%baz', reader => 'baz' ); |
15 | } |
16 | |
17 | { |
18 | my $meta = Foo->meta; |
19 | |
20 | for my $name ( '@foo', '!bar', '%baz' ) { |
21 | ok( |
22 | $meta->has_attribute($name), |
23 | "Foo has $name attribute" |
24 | ); |
25 | |
26 | my $meth = substr $name, 1; |
27 | ok( $meta->has_method($meth), 'Foo has $meth method' ); |
28 | } |
29 | |
30 | $meta->make_immutable, redo |
31 | unless $meta->is_immutable; |
32 | } |
33 | |
34 | done_testing; |