Commit | Line | Data |
67199842 |
1 | #!/usr/bin/perl |
fde8e43f |
2 | # This is automatically generated by author/import-moose-test.pl. |
3 | # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! |
4 | use t::lib::MooseCompat; |
67199842 |
5 | |
6 | use strict; |
7 | use warnings; |
8 | |
6475f69d |
9 | use Test::More; |
67199842 |
10 | use Test::Exception; |
11 | use Scalar::Util 'blessed'; |
12 | |
13 | |
67199842 |
14 | { |
15 | package Dog; |
16 | use Mouse::Role; |
17 | |
18 | sub talk { 'woof' } |
19 | |
20 | package Foo; |
21 | use Mouse; |
22 | |
23 | has 'dog' => ( |
24 | is => 'rw', |
25 | does => 'Dog', |
26 | ); |
27 | |
28 | no Mouse; |
29 | |
30 | package Bar; |
31 | |
32 | sub new { |
33 | return bless {}, shift; |
34 | } |
35 | } |
36 | |
37 | my $bar = Bar->new; |
6cfa1e5e |
38 | isa_ok($bar, 'Bar'); |
67199842 |
39 | |
40 | my $foo = Foo->new; |
6cfa1e5e |
41 | isa_ok($foo, 'Foo'); |
67199842 |
42 | |
43 | ok(!$bar->can( 'talk' ), "... the role is not composed yet"); |
44 | |
45 | dies_ok { |
46 | $foo->dog($bar) |
47 | } '... and setting the accessor fails (not a Dog yet)'; |
48 | |
49 | Dog->meta->apply($bar); |
50 | |
51 | ok($bar->can('talk'), "... the role is now composed at the object level"); |
52 | |
53 | is($bar->talk, 'woof', '... got the right return value for the newly composed method'); |
54 | |
55 | lives_ok { |
56 | $foo->dog($bar) |
57 | } '... and setting the accessor is okay'; |
58 | |
6475f69d |
59 | done_testing; |