File: 02-meta.t

package info (click to toggle)
libmoosex-has-options-perl 0.003-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 152 kB
  • sloc: perl: 186; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 851 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
30
31
32
33
34
35
36
37
38
39
use strict;
use warnings;

use Test::Most;

{
    package TestOptions;

    use Moose;
    use MooseX::Has::Options;
    use namespace::autoclean;

    has 'plain_attribute' =>
    (
        qw(:ro :required),
        isa => 'Str',
    );

    has 'attribute_with_options' =>
    (
        qw(:ro :lazy_build),
        isa => 'Str'
    );

    sub _build_attribute_with_options
    {
        return 'SomeRandomValue';
    }
}

my $meta = TestOptions->new( plain_attribute => 'Plain')->meta;
my $plain_attribute        = $meta->get_attribute('plain_attribute');
my $attribute_with_options = $meta->get_attribute('attribute_with_options');

ok( !$plain_attribute->has_write_method,    'meta read only'  );
ok( $plain_attribute->is_required,          'meta required'   );
ok( $attribute_with_options->is_lazy_build, 'meta lazy build' );

done_testing();