Commit | Line | Data |
f1bad247 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | use Test::More; |
5 | use Test::Fatal; |
6 | use Moo::Object; |
7 | |
8 | # See RT#84615 |
9 | |
10 | ok( Moo::Object->can('meta'), 'Moo::Object can meta'); |
11 | is( exception { Moo::Object->meta->can('can') } , undef, "Moo::Object->meta->can doesn't explode" ); |
12 | |
13 | { |
14 | package Example; |
15 | use base 'Moo::Object'; |
16 | |
17 | } |
18 | |
19 | ok( Example->can('meta'), 'Example can meta'); |
20 | is( exception { Example->meta->can('can') } , undef, "Example->meta->can doesn't explode" ); |
21 | |
22 | # Haarg++ noting that previously, this *also* would have died due to its absence from %Moo::Makers; |
23 | { |
24 | package Example_2; |
25 | use Moo; |
26 | |
27 | has 'attr' => ( is => ro =>, ); |
28 | |
29 | $INC{'Example_2.pm'} = 1; |
30 | } |
31 | { |
32 | package Example_3; |
33 | use base "Example_2"; |
34 | } |
35 | |
36 | ok( Example_2->can('meta'), 'Example_2 can meta') and subtest meta_checks_for_Example_2 => sub { |
37 | return unless ok( Example_2->meta->can('get_all_attributes'), 'Example_2 meta can get_all_attributes' ); |
38 | my (@attributes) = Example_2->meta->get_all_attributes; |
39 | is( scalar @attributes, 1, 'Has one attribute' ); |
40 | }; |
41 | |
42 | ok( Example_3->can('meta'), 'Example_3 can meta') and subtest meta_checks_for_Example_3 => sub { |
43 | return unless is( exception { Example_3->meta->can('can') } , undef, "Example_3->meta->can doesn't explode" ); |
44 | return unless ok( Example_3->meta->can('get_all_attributes'), 'Example_3 meta can get_all_attributes' ); |
45 | my (@attributes) = Example_3->meta->get_all_attributes; |
46 | is( scalar @attributes, 1, 'Has one attribute' ); |
47 | }; |
48 | |
49 | done_testing; |