6 use Test::More tests => 21;
14 has 'bar' => (is => 'ro');
19 has 'baz' => (is => 'ro', default => 'BAZ');
24 my $foo = Foo->new(bar => 'BAR');
27 is($foo->bar, 'BAR', '... got the expect value');
28 ok(!$foo->can('baz'), '... no baz method though');
31 Bar->meta->apply($foo)
34 is($foo->bar, 'BAR', '... got the expect value');
35 ok($foo->can('baz'), '... we have baz method now');
36 is($foo->baz, 'BAZ', '... got the expect value');
39 # with extra params ...
41 my $foo = Foo->new(bar => 'BAR');
44 is($foo->bar, 'BAR', '... got the expect value');
45 ok(!$foo->can('baz'), '... no baz method though');
48 Bar->meta->apply($foo, (rebless_params => { baz => 'FOO-BAZ' }))
51 is($foo->bar, 'BAR', '... got the expect value');
52 ok($foo->can('baz'), '... we have baz method now');
53 is($foo->baz, 'FOO-BAZ', '... got the expect value');
56 # with extra params ...
58 my $foo = Foo->new(bar => 'BAR');
61 is($foo->bar, 'BAR', '... got the expect value');
62 ok(!$foo->can('baz'), '... no baz method though');
65 Bar->meta->apply($foo, (rebless_params => { bar => 'FOO-BAR', baz => 'FOO-BAZ' }))
68 is($foo->bar, 'FOO-BAR', '... got the expect value');
69 ok($foo->can('baz'), '... we have baz method now');
70 is($foo->baz, 'FOO-BAZ', '... got the expect value');