Make sure is => undef works
Shawn M Moore [Fri, 10 Jul 2009 06:15:49 +0000 (02:15 -0400)]
t/003-no-accessor.t [new file with mode: 0644]

diff --git a/t/003-no-accessor.t b/t/003-no-accessor.t
new file mode 100644 (file)
index 0000000..c1b8a2f
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 5;
+use Test::Exception;
+
+do {
+    package Person;
+    use Moose;
+    use MooseX::IsDefaults::RO;
+
+    has name => (
+        isa => 'Str',
+    );
+
+    has blah => (
+        is        => undef,
+        predicate => 'has_blah',
+    );
+};
+
+can_ok(Person => qw(name));
+ok(!Person->can('blah'));
+
+my $person = Person->new(name => 'Joe', blah => 'secret');
+is($person->name, 'Joe');
+is($person->{blah}, 'secret', 'an attribute was created even though it has no accessor');
+ok($person->has_blah);
+