6 use Test::More tests => 22;
16 has 'bar' => (is => 'ro');
21 has 'baz' => (is => 'ro', default => 'BAZ');
26 my $foo = Foo->new(bar => 'BAR');
29 is($foo->bar, 'BAR', '... got the expect value');
30 ok(!$foo->can('baz'), '... no baz method though');
33 Bar->meta->apply($foo)
36 is($foo->bar, 'BAR', '... got the expect value');
37 ok($foo->can('baz'), '... we have baz method now');
38 is($foo->baz, 'BAZ', '... got the expect value');
41 # with extra params ...
43 my $foo = Foo->new(bar => 'BAR');
46 is($foo->bar, 'BAR', '... got the expect value');
47 ok(!$foo->can('baz'), '... no baz method though');
50 Bar->meta->apply($foo, (rebless_params => { baz => 'FOO-BAZ' }))
53 is($foo->bar, 'BAR', '... got the expect value');
54 ok($foo->can('baz'), '... we have baz method now');
55 is($foo->baz, 'FOO-BAZ', '... got the expect value');
58 # with extra params ...
60 my $foo = Foo->new(bar => 'BAR');
63 is($foo->bar, 'BAR', '... got the expect value');
64 ok(!$foo->can('baz'), '... no baz method though');
67 Bar->meta->apply($foo, (rebless_params => { bar => 'FOO-BAR', baz => 'FOO-BAZ' }))
70 is($foo->bar, 'FOO-BAR', '... got the expect value');
71 ok($foo->can('baz'), '... we have baz method now');
72 is($foo->baz, 'FOO-BAZ', '... got the expect value');