Add a test for weakref stuff
gfx [Mon, 16 Nov 2009 12:23:05 +0000 (21:23 +0900)]
t/001_mouse/059-weak-with-default.t [new file with mode: 0644]

diff --git a/t/001_mouse/059-weak-with-default.t b/t/001_mouse/059-weak-with-default.t
new file mode 100644 (file)
index 0000000..5a5a46d
--- /dev/null
@@ -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);