update repo to point to github
[gitmo/Moo.git] / xt / moo-object-meta-can.t
1 use strictures 1;
2 use Test::More;
3 use Test::Fatal;
4 use Moo::Object;
5
6 # See RT#84615
7
8 ok( Moo::Object->can('meta'), 'Moo::Object can meta');
9 is( exception { Moo::Object->meta->can('can') } , undef, "Moo::Object->meta->can doesn't explode" );
10
11 {
12     package Example;
13     use base 'Moo::Object';
14
15 }
16
17 ok( Example->can('meta'), 'Example can meta');
18 is( exception { Example->meta->can('can') } , undef, "Example->meta->can doesn't explode" );
19
20 # Haarg++ noting that previously, this *also* would have died due to its absence from %Moo::Makers;
21 {
22     package Example_2;
23     use Moo;
24
25     has 'attr' => ( is => ro =>, );
26
27     $INC{'Example_2.pm'} = 1;
28 }
29 {
30     package Example_3;
31     use base "Example_2";
32 }
33
34 ok( Example_2->can('meta'), 'Example_2 can meta') and do {
35     return unless ok( Example_2->meta->can('get_all_attributes'), 'Example_2 meta can get_all_attributes' );
36     my (@attributes) = Example_2->meta->get_all_attributes;
37     is( scalar @attributes, 1, 'Has one attribute' );
38 };
39
40 ok( Example_3->can('meta'), 'Example_3 can meta') and do {
41     return unless is( exception { Example_3->meta->can('can') } , undef, "Example_3->meta->can doesn't explode" );
42     return unless ok( Example_3->meta->can('get_all_attributes'), 'Example_3 meta can get_all_attributes' );
43     my (@attributes) = Example_3->meta->get_all_attributes;
44     is( scalar @attributes, 1, 'Has one attribute' );
45 };
46
47 done_testing;