From: gfx Date: Mon, 16 Nov 2009 12:23:05 +0000 (+0900) Subject: Add a test for weakref stuff X-Git-Tag: 0.40_07~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=434bcb421e7255eb49733765c29bf014e3a52e91 Add a test for weakref stuff --- diff --git a/t/001_mouse/059-weak-with-default.t b/t/001_mouse/059-weak-with-default.t new file mode 100644 index 0000000..5a5a46d --- /dev/null +++ b/t/001_mouse/059-weak-with-default.t @@ -0,0 +1,35 @@ +#!perl +use strict; +use warnings; +use Test::More tests => 4; + +{ + package MyClass; + use Mouse; + + has lazy_weak_with_default => ( + is => 'rw', + isa => 'Ref', + weak_ref => 1, + lazy => 1, + default => sub{ [] }, + ); + + has weak_with_default => ( + is => 'rw', + isa => 'Ref', + weak_ref => 1, + default => sub{ [] }, + ); + +} + +my $o = MyClass->new(); +is($o->weak_with_default, undef); +is($o->lazy_weak_with_default, undef); + +MyClass->meta->make_immutable(); + +$o = MyClass->new(); +is($o->weak_with_default, undef); +is($o->lazy_weak_with_default, undef);