File: 09-bare-native-traits.t

package info (click to toggle)
libmoosex-classattribute-perl 0.27-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 244 kB
  • ctags: 47
  • sloc: perl: 994; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 639 bytes parent folder | download | duplicates (2)
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
# reported in https://rt.cpan.org/Public/Bug/Display.html?id=59573

use strict;
use warnings;

use Test::More;
use Test::Fatal;

{
    package Foo;

    use Moose;
    use MooseX::ClassAttribute;

    class_has attr => (
        is      => 'bare',
        isa     => 'HashRef[Str]',
        lazy    => 1,
        default => sub { {} },
        traits  => ['Hash'],
        handles => {
            has_attr => 'exists',
        },
    );
}

is(
    exception { Foo->has_attr('key') },
    undef,
    'Default builder in a native attribute trait is properly run when the attribute is defined with no standard accessors'
);

done_testing();