diff options
Diffstat (limited to 't')
| -rw-r--r-- | t/14_private_attribute.t | 40 | ||||
| -rw-r--r-- | t/15_protected_attribute.t | 34 |
2 files changed, 40 insertions, 34 deletions
diff --git a/t/14_private_attribute.t b/t/14_private_attribute.t index 811294a..0050298 100644 --- a/t/14_private_attribute.t +++ b/t/14_private_attribute.t @@ -5,22 +5,34 @@ use Test::More tests => 10; use Test::Exception; use Test::Moose; -{ - - package Foo; - use Moose; - use MooseX::Privacy; - - has foo => ( is => 'rw', isa => 'Str', traits => [qw/Private/] ); - sub bar { my $self = shift; $self->foo('bar'); $self->foo } +package Foo; +use Moose; +use MooseX::Privacy; + +has foo => ( + is => 'rw', + isa => 'Str', + lazy => 1, + default => 'test', + traits => [qw/Private/] +); + +sub bar { + my $self = shift; + $self->foo('bar'); + $self->foo; } -{ +package Bar; +use Moose; - package Bar; - use Moose; - has bar => ( is => 'rw', isa => 'Str', traits => [qw/Private/] ); -} +has bar => ( + is => 'rw', + isa => 'Str', + traits => [qw/Private/] +); + +package main; with_immutable { ok my $foo = Foo->new(); @@ -31,5 +43,3 @@ with_immutable { ok my $bar = Bar->new(); } (qw/Foo Bar/); - - diff --git a/t/15_protected_attribute.t b/t/15_protected_attribute.t index fe3fd9a..36e8f66 100644 --- a/t/15_protected_attribute.t +++ b/t/15_protected_attribute.t @@ -5,28 +5,24 @@ use Test::More tests => 10; use Test::Exception; use Test::Moose; -{ - - package Foo; - use Moose; - use MooseX::Privacy; - - has foo => ( - is => 'rw', - isa => 'Str', - traits => [qw/Protected/], - default => 'foo' - ); -} +package Foo; +use Moose; +use MooseX::Privacy; -{ +has foo => ( + is => 'rw', + isa => 'Str', + traits => [qw/Protected/], + default => 'foo' +); - package Bar; - use Moose; - extends 'Foo'; +package Bar; +use Moose; +extends 'Foo'; - sub bar { (shift)->foo } -} +sub bar { (shift)->foo } + +package main; with_immutable { ok my $foo = Foo->new(); |
