summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--t/10_private_method.t27
-rw-r--r--t/11_protected_method.t24
-rw-r--r--t/14_private_attribute.t18
-rw-r--r--t/15_protected_attribute.t19
4 files changed, 50 insertions, 38 deletions
diff --git a/t/10_private_method.t b/t/10_private_method.t
index b2f3056..9948983 100644
--- a/t/10_private_method.t
+++ b/t/10_private_method.t
@@ -1,8 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 7;
+use Test::More tests => 14;
use Test::Exception;
+use Test::Moose;
{
@@ -45,16 +46,20 @@ use Test::Exception;
}
}
-my $foo = Foo->new();
-isa_ok( $foo, 'Foo' );
-dies_ok { $foo->bar } "... can't call bar, method is private";
-is $foo->baz, 'baz', "... got the good value from &baz";
-is $foo->foo('baz'), 'foobarbaz', "... got the good value from &foobar";
+with_immutable {
+ my $foo = Foo->new();
+ isa_ok( $foo, 'Foo' );
+ dies_ok { $foo->bar } "... can't call bar, method is private";
+ is $foo->baz, 'baz', "... got the good value from &baz";
+ is $foo->foo('baz'), 'foobarbaz', "... got the good value from &foobar";
+ my $bar = Bar->new();
+ isa_ok( $bar, 'Bar' );
+ dies_ok { $bar->newbar() } "... can't call bar, method is private";
+
+ is scalar @{ $foo->meta->local_private_methods }, 2,
+ '... got two privates method';
+}
+(qw/Foo Bar/);
-my $bar = Bar->new();
-isa_ok( $bar, 'Bar' );
-dies_ok { $bar->newbar() } "... can't call bar, method is private";
-is scalar @{ $foo->meta->local_private_methods }, 2,
- '... got two privates method';
diff --git a/t/11_protected_method.t b/t/11_protected_method.t
index 3618069..a7ef35f 100644
--- a/t/11_protected_method.t
+++ b/t/11_protected_method.t
@@ -1,8 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More tests => 10;
use Test::Exception;
+use Test::Moose;
{
@@ -28,16 +29,17 @@ use Test::Exception;
}
}
-my $foo = Foo->new();
-isa_ok( $foo, 'Foo' );
-dies_ok { $foo->bar } "... can't call bar, method is protected";
-
-my $bar = Bar->new();
-isa_ok( $bar, 'Bar' );
-is $bar->baz(), 'baz', "... got the good value from &bar";
-
-is scalar @{ $foo->meta->local_protected_methods }, 1,
- '... got one protected method';
+with_immutable {
+ my $foo = Foo->new();
+ isa_ok( $foo, 'Foo' );
+ dies_ok { $foo->bar } "... can't call bar, method is protected";
+ my $bar = Bar->new();
+ isa_ok( $bar, 'Bar' );
+ is $bar->baz(), 'baz', "... got the good value from &bar";
+ is scalar @{ $foo->meta->local_protected_methods }, 1,
+ '... got one protected method';
+}
+(qw/Foo Bar/);
diff --git a/t/14_private_attribute.t b/t/14_private_attribute.t
index 70ff5d1..811294a 100644
--- a/t/14_private_attribute.t
+++ b/t/14_private_attribute.t
@@ -1,8 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More tests => 10;
use Test::Exception;
+use Test::Moose;
{
@@ -14,12 +15,6 @@ use Test::Exception;
sub bar { my $self = shift; $self->foo('bar'); $self->foo }
}
-ok my $foo = Foo->new();
-
-dies_ok { $foo->foo };
-ok $foo->bar;
-is scalar @{ $foo->meta->local_private_attributes }, 1;
-
{
package Bar;
@@ -27,7 +22,14 @@ is scalar @{ $foo->meta->local_private_attributes }, 1;
has bar => ( is => 'rw', isa => 'Str', traits => [qw/Private/] );
}
-ok my $bar = Bar->new();
+with_immutable {
+ ok my $foo = Foo->new();
+ dies_ok { $foo->foo };
+ ok $foo->bar;
+ is scalar @{ $foo->meta->local_private_attributes }, 1;
+ ok my $bar = Bar->new();
+}
+(qw/Foo Bar/);
diff --git a/t/15_protected_attribute.t b/t/15_protected_attribute.t
index 3c2ae8d..fe3fd9a 100644
--- a/t/15_protected_attribute.t
+++ b/t/15_protected_attribute.t
@@ -1,8 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More tests => 10;
use Test::Exception;
+use Test::Moose;
{
@@ -24,16 +25,18 @@ use Test::Exception;
use Moose;
extends 'Foo';
- sub bar { (shift)->foo };
+ sub bar { (shift)->foo }
}
-ok my $foo = Foo->new();
-dies_ok { $foo->foo };
-is scalar @{ $foo->meta->local_protected_attributes }, 1;
-
-ok my $bar = Bar->new();
-ok $bar->bar();
+with_immutable {
+ ok my $foo = Foo->new();
+ dies_ok { $foo->foo };
+ is scalar @{ $foo->meta->local_protected_attributes }, 1;
+ ok my $bar = Bar->new();
+ ok $bar->bar();
+}
+(qw/Foo Bar/);