From: Dave Rolsky Date: Fri, 16 Sep 2011 14:44:11 +0000 (-0500) Subject: Add tests for insertion order when an attr is removed and re-added X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f5f4219a381e926cd9043d4e2bab6ec3269a58d5;p=gitmo%2FMoose.git Add tests for insertion order when an attr is removed and re-added --- diff --git a/t/cmop/insertion_order.t b/t/cmop/insertion_order.t index 073d3b3..e057a44 100644 --- a/t/cmop/insertion_order.t +++ b/t/cmop/insertion_order.t @@ -32,4 +32,32 @@ my $Point = Class::MOP::Class->create('Point' => ( 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"'); +{ + my $class = Class::MOP::Class->create('Foo'); + + $class->add_attribute('first'); + $class->add_attribute('second'); + + is( + $class->get_attribute('first')->insertion_order, 0, + 'insertion_order for first is 0' + ); + is( + $class->get_attribute('second')->insertion_order, 1, + 'insertion_order for second is 1' + ); + + $class->add_attribute('first'); + + is( + $class->get_attribute('first')->insertion_order, 0, + 'insertion_order for first is still 0 after removing and readding first' + ); + + is( + $class->get_attribute('second')->insertion_order, 1, + 'insertion_order for second is still 0 after removing and readding first' + ); +} + done_testing;