From: nperez Date: Fri, 8 May 2009 18:30:12 +0000 (-0500) Subject: add test for insertion order X-Git-Tag: 0.84~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e237c683f56c8c01533b0213c02d1d9f3832fc67;p=gitmo%2FClass-MOP.git add test for insertion order --- diff --git a/t/308_insertion_order.t b/t/308_insertion_order.t new file mode 100644 index 0000000..9a66782 --- /dev/null +++ b/t/308_insertion_order.t @@ -0,0 +1,35 @@ +use Class::MOP; + +use Test::More('tests', 2); + + +my $Point = Class::MOP::Class->create('Point' => ( + version => '0.01', + attributes => [ + Class::MOP::Attribute->new('x' => ( + reader => 'x', + init_arg => 'x' + )), + Class::MOP::Attribute->new('y' => ( + accessor => 'y', + init_arg => 'y' + )), + ], + methods => { + 'new' => sub { + my $class = shift; + my $instance = $class->meta->new_object(@_); + bless $instance => $class; + }, + 'clear' => sub { + my $self = shift; + $self->{'x'} = 0; + $self->{'y'} = 0; + } + } +)); + +is($Point->get_attribute('x')->insertion_order, 0, 'Insertion order of Attribute "x"'); +is($Point->get_attribute('y')->insertion_order, 1, 'Insertion order of Attribute "y"'); + +1;