Regenerate test files
[gitmo/Mouse.git] / t / 030_roles / 018_runtime_roles_w_params.t
1 #!/usr/bin/perl
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;
5
6 use strict;
7 use warnings;
8
9 use Test::More;
10 $TODO = q{Mouse is not yet completed};
11 use Test::Exception;
12
13
14 {
15     package Foo;
16     use Mouse;
17     has 'bar' => (is => 'ro');
18
19     package Bar;
20     use Mouse::Role;
21
22     has 'baz' => (is => 'ro', default => 'BAZ');
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');
56     is($foo->baz, 'FOO-BAZ', '... got the expect value');
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
71     is($foo->bar, 'FOO-BAR', '... got the expect value');
72     ok($foo->can('baz'), '... we have baz method now');
73     is($foo->baz, 'FOO-BAZ', '... got the expect value');
74 }
75
76 done_testing;