File: 003-no-accessor.t

package info (click to toggle)
libmoosex-hasdefaults-perl 0.03-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 1,369; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 561 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 5;
use Test::Exception;

do {
    package Person;
    use Moose;
    use MooseX::HasDefaults::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);