Commit | Line | Data |
21fd40b0 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | use Test::More; |
5 | |
6 | { |
7 | package Foo::Role; |
8 | use Moose::Role; |
9 | has 'a' => (is => 'ro'); |
10 | has 'b' => (is => 'ro'); |
11 | has 'c' => (is => 'ro'); |
12 | } |
13 | |
14 | { |
15 | package Foo; |
16 | use Moose; |
17 | has 'd' => (is => 'ro'); |
18 | with 'Foo::Role'; |
19 | has 'e' => (is => 'ro'); |
20 | } |
21 | |
22 | my %role_insertion_order = ( |
23 | a => 0, |
24 | b => 1, |
25 | c => 2, |
26 | ); |
27 | |
28 | is_deeply({ map { $_->name => $_->insertion_order } map { Foo::Role->meta->get_attribute($_) } Foo::Role->meta->get_attribute_list }, \%role_insertion_order, "right insertion order within the role"); |
29 | |
30 | my %class_insertion_order = ( |
31 | d => 0, |
32 | a => 1, |
33 | b => 2, |
34 | c => 3, |
35 | e => 4, |
36 | ); |
37 | |
38 | { local $TODO = "insertion order is lost during role application"; |
39 | is_deeply({ map { $_->name => $_->insertion_order } Foo->meta->get_all_attributes }, \%class_insertion_order, "right insertion order within the class"); |
40 | } |
41 | |
42 | done_testing; |