File: moose-autoclean-lazy-attr-builders.t

package info (click to toggle)
libmoo-perl 1.006001-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 772 kB
  • ctags: 202
  • sloc: perl: 2,348; sh: 18; makefile: 6
file content (31 lines) | stat: -rw-r--r-- 577 bytes parent folder | download
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
use strict;
use warnings;
# when using an Moose object and namespace::autoclean
# lazy attributes that get a value on initialize still
# have their builders run

{
    package MyMooseObject;
    use Moose;
}

{
    package BadObject;
    use Moo;
    # use MyMooseObject <- this is inferred here
    use namespace::autoclean;

    has attr => ( is => 'lazy' );
    sub _build_attr {2}
}

use Test::More;
# use BadObject <- this is inferred here

is(
    BadObject->new( attr => 1 )->attr,
    1,
    q{namespace::autoclean doesn't run builders with default},
);

done_testing;