MooClass->meta
[gitmo/Moo.git] / t / accessor-default.t
CommitLineData
46389f86 1use strictures 1;
2use Test::More;
3
4{
5 package Foo;
6
7 use Sub::Quote;
b1eebd55 8 use Moo;
46389f86 9
10 has one => (is => 'ro', lazy => 1, default => quote_sub q{ {} });
11 has two => (is => 'ro', lazy => 1, builder => '_build_two');
12 sub _build_two { {} }
13 has three => (is => 'ro', default => quote_sub q{ {} });
649ac264 14 has four => (is => 'ro', builder => '_build_four');
46389f86 15 sub _build_four { {} }
d02da2bc 16 has five => (is => 'ro', init_arg => undef, default => sub { {} });
e8dc5201 17 has six => (is => 'ro', builder => 1);
18 sub _build_six { {} }
46389f86 19}
20
21sub check {
22 my ($attr, @h) = @_;
23
24 is_deeply($h[$_], {}, "${attr}: empty hashref \$h[$_]") for 0..1;
25
26 isnt($h[0],$h[1], "${attr}: not the same hashref");
27}
28
29check one => map Foo->new->one, 1..2;
30
31check two => map Foo->new->two, 1..2;
32
649ac264 33check three => map Foo->new->{three}, 1..2;
34
35check four => map Foo->new->{four}, 1..2;
36
d02da2bc 37check five => map Foo->new->{five}, 1..2;
38
e8dc5201 39check six => map Foo->new->{six}, 1..2;
40
46389f86 41done_testing;