projects
/
gitmo/Moose.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
55a060455b8ca1c460c119788ddc41b605b3486a
[gitmo/Moose.git]
/
t
/
attributes
/
clone_weak.t
1
use strict;
2
use warnings;
3
use Test::More;
4
5
{
6
package Foo;
7
use Moose;
8
9
has bar => (
10
is => 'ro',
11
weak_ref => 1,
12
);
13
}
14
15
{
16
package MyScopeGuard;
17
18
sub new {
19
my ($class, $cb) = @_;
20
bless { cb => $cb }, $class;
21
}
22
23
sub DESTROY { shift->{cb}->() }
24
}
25
26
{
27
my $destroyed = 0;
28
29
my $foo = do {
30
my $bar = MyScopeGuard->new(sub { $destroyed++ });
31
my $foo = Foo->new({ bar => $bar });
32
my $clone = $foo->meta->clone_object($foo);
33
34
is $destroyed, 0;
35
36
$clone;
37
};
38
39
isa_ok($foo, 'Foo');
40
is $foo->bar, undef;
41
is $destroyed, 1;
42
}
43
44
done_testing;