Test that a lazy attr without a default or builder dies
Dave Rolsky [Sun, 31 Oct 2010 16:24:14 +0000 (11:24 -0500)]
t/020_attributes/040_lazy_no_default.t [new file with mode: 0644]

diff --git a/t/020_attributes/040_lazy_no_default.t b/t/020_attributes/040_lazy_no_default.t
new file mode 100644 (file)
index 0000000..bb35a08
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Fatal;
+
+{
+    package Foo;
+    use Moose;
+
+    ::like(
+        ::exception{ has foo => (
+                is   => 'ro',
+                lazy => 1,
+            );
+            },
+        qr/\QYou cannot have a lazy attribute (foo) without specifying a default value for it/,
+        'lazy without a default or builder throws an error'
+    );
+}
+
+done_testing;