summaryrefslogtreecommitdiff
path: root/t/04arrayofattrs.t
blob: ce3058ecd49787a47664ba3967d0c78153b6e445 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
=head1 PURPOSE

Test that this works:

	has \@attributes => (...);

Specifically we test is for C<lazy_build> as that's a kinda interesting
one.

=head1 AUTHOR

Toby Inkster E<lt>tobyink@cpan.orgE<gt>.

=head1 COPYRIGHT AND LICENCE

This software is copyright (c) 2012-2014, 2019 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut

use strict;
use warnings;
use Test::More;

{
	package Local::Role;
	use Moo::Role;
	use MooX::late;
	has [qw(foo1 foo2)] => (is => 'ro', isa => 'Str', lazy_build => 1);
	sub _build_foo1 { 'foo1' };
	sub _build_foo2 { 'foo2' };
}

{
	package Local::Class;
	use Moo;
	use MooX::late;
	with 'Local::Role';
	has [qw(bar1 bar2)] => (is => 'ro', isa => 'Str', lazy_build => 1);
	sub _build_bar1 { 'bar1' };
	sub _build_bar2 { 'bar2' };
}

my $o1 = Local::Class->new;
is($o1->foo1, 'foo1');
is($o1->foo2, 'foo2');
is($o1->bar1, 'bar1');
is($o1->bar2, 'bar2');

done_testing;