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 | |
fde8e43f |
9 | use Test::More; |
10 | $TODO = q{Mouse is not yet completed}; |
67199842 |
11 | use Test::Exception; |
12 | |
13 | |
67199842 |
14 | { |
15 | package Foo; |
16 | use Mouse; |
17 | has 'bar' => (is => 'ro'); |
6cfa1e5e |
18 | |
67199842 |
19 | package Bar; |
20 | use Mouse::Role; |
6cfa1e5e |
21 | |
22 | has 'baz' => (is => 'ro', default => 'BAZ'); |
67199842 |
23 | } |
24 | |
25 | # normal ... |
26 | { |
27 | my $foo = Foo->new(bar => 'BAR'); |
28 | isa_ok($foo, 'Foo'); |
29 | |
30 | is($foo->bar, 'BAR', '... got the expect value'); |
31 | ok(!$foo->can('baz'), '... no baz method though'); |
32 | |
33 | lives_ok { |
34 | Bar->meta->apply($foo) |
35 | } '... this works'; |
36 | |
37 | is($foo->bar, 'BAR', '... got the expect value'); |
38 | ok($foo->can('baz'), '... we have baz method now'); |
39 | is($foo->baz, 'BAZ', '... got the expect value'); |
40 | } |
41 | |
42 | # with extra params ... |
43 | { |
44 | my $foo = Foo->new(bar => 'BAR'); |
45 | isa_ok($foo, 'Foo'); |
46 | |
47 | is($foo->bar, 'BAR', '... got the expect value'); |
48 | ok(!$foo->can('baz'), '... no baz method though'); |
49 | |
50 | lives_ok { |
51 | Bar->meta->apply($foo, (rebless_params => { baz => 'FOO-BAZ' })) |
52 | } '... this works'; |
53 | |
54 | is($foo->bar, 'BAR', '... got the expect value'); |
55 | ok($foo->can('baz'), '... we have baz method now'); |
fde8e43f |
56 | is($foo->baz, 'FOO-BAZ', '... got the expect value'); |
67199842 |
57 | } |
58 | |
59 | # with extra params ... |
60 | { |
61 | my $foo = Foo->new(bar => 'BAR'); |
62 | isa_ok($foo, 'Foo'); |
63 | |
64 | is($foo->bar, 'BAR', '... got the expect value'); |
65 | ok(!$foo->can('baz'), '... no baz method though'); |
66 | |
67 | lives_ok { |
68 | Bar->meta->apply($foo, (rebless_params => { bar => 'FOO-BAR', baz => 'FOO-BAZ' })) |
69 | } '... this works'; |
70 | |
fde8e43f |
71 | is($foo->bar, 'FOO-BAR', '... got the expect value'); |
67199842 |
72 | ok($foo->can('baz'), '... we have baz method now'); |
fde8e43f |
73 | is($foo->baz, 'FOO-BAZ', '... got the expect value'); |
67199842 |
74 | } |
75 | |
fde8e43f |
76 | done_testing; |