Include method name in immutable methods (fixes #49680)
[gitmo/Class-MOP.git] / t / 301_RT_27329_fix.t
CommitLineData
795a0c8b 1use strict;
2use warnings;
3
efd3d14c 4use Test::More tests => 8;
795a0c8b 5
efd3d14c 6use Class::MOP;
795a0c8b 7
8=pod
9
10This tests a bug sent via RT #27329
11
12=cut
13
14{
15 package Foo;
16 use metaclass;
17
18 Foo->meta->add_attribute('foo' => (
19 init_arg => 'foo',
20 reader => 'get_foo',
21 default => 'BAR',
22 ));
23
24}
25
26my $foo = Foo->meta->new_object;
27isa_ok($foo, 'Foo');
28
29is($foo->get_foo, 'BAR', '... got the right default value');
30
31{
32 my $clone = $foo->meta->clone_object($foo, foo => 'BAZ');
33 isa_ok($clone, 'Foo');
34 isnt($clone, $foo, '... and it is a clone');
35
36 is($clone->get_foo, 'BAZ', '... got the right cloned value');
37}
38
39{
40 my $clone = $foo->meta->clone_object($foo, foo => undef);
41 isa_ok($clone, 'Foo');
42 isnt($clone, $foo, '... and it is a clone');
43
44 ok(!defined($clone->get_foo), '... got the right cloned value');
45}
46
47
48
49
50
51