Commit | Line | Data |
38bf2a25 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | use Class::MOP; |
5 | |
6 | my $Point = Class::MOP::Class->create('Point' => ( |
7 | version => '0.01', |
8 | attributes => [ |
9 | Class::MOP::Attribute->new('x' => ( |
10 | reader => 'x', |
11 | init_arg => 'x' |
12 | )), |
13 | Class::MOP::Attribute->new('y' => ( |
14 | accessor => 'y', |
15 | init_arg => 'y' |
16 | )), |
17 | ], |
18 | methods => { |
19 | 'new' => sub { |
20 | my $class = shift; |
21 | my $instance = $class->meta->new_object(@_); |
22 | bless $instance => $class; |
23 | }, |
24 | 'clear' => sub { |
25 | my $self = shift; |
26 | $self->{'x'} = 0; |
27 | $self->{'y'} = 0; |
28 | } |
29 | } |
30 | )); |
31 | |
32 | is($Point->get_attribute('x')->insertion_order, 0, 'Insertion order of Attribute "x"'); |
33 | is($Point->get_attribute('y')->insertion_order, 1, 'Insertion order of Attribute "y"'); |
34 | |
35 | done_testing; |