File: 301_RT_27329_fix.t

package info (click to toggle)
libclass-mop-perl 1.04-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,244 kB
  • ctags: 1,272
  • sloc: perl: 5,192; ansic: 241; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use strict;
use warnings;

use Test::More;

use Class::MOP;

=pod

This tests a bug sent via RT #27329

=cut

{
    package Foo;
    use metaclass;

    Foo->meta->add_attribute('foo' => (
        init_arg => 'foo',
        reader   => 'get_foo',
        default  => 'BAR',
    ));

}

my $foo = Foo->meta->new_object;
isa_ok($foo, 'Foo');

is($foo->get_foo, 'BAR', '... got the right default value');

{
    my $clone = $foo->meta->clone_object($foo, foo => 'BAZ');
    isa_ok($clone, 'Foo');
    isnt($clone, $foo, '... and it is a clone');

    is($clone->get_foo, 'BAZ', '... got the right cloned value');
}

{
    my $clone = $foo->meta->clone_object($foo, foo => undef);
    isa_ok($clone, 'Foo');
    isnt($clone, $foo, '... and it is a clone');

    ok(!defined($clone->get_foo), '... got the right cloned value');
}

done_testing;