Make get_all_attributes() sorted by their definition order
[gitmo/Mouse.git] / author / attr_order.pl
diff --git a/author/attr_order.pl b/author/attr_order.pl
new file mode 100644 (file)
index 0000000..14c688b
--- /dev/null
@@ -0,0 +1,31 @@
+package Base;
+use Any::Moose;
+
+has [qw(aaa bbb ccc)] => (
+    is => 'rw',
+);
+
+package D1;
+use Any::Moose;
+extends qw(Base);
+has [qw(ddd eee fff)] => (
+    is => 'rw',
+);
+
+package D2;
+use Any::Moose;
+extends qw(D1);
+has [qw(ggg hhh iii)] => (
+    is => 'rw',
+);
+
+package main;
+use Test::More;
+use Test::Mouse;
+
+with_immutable {
+    my $attrs_list = join ",",
+        map { $_->name } D2->meta->get_all_attributes;
+    is $attrs_list, join ",", qw(aaa bbb ccc ddd eee fff ggg hhh iii);
+} qw(Base D1 D2);
+done_testing;