summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-02-21 01:53:08 -0600
committerJesse Luehrs <doy@tozt.net>2011-02-21 01:53:08 -0600
commit06f919c57dfc917e50e6858100cfbe3a1b57a1be (patch)
tree8d269551288407c1cc78c9d7ad7466cf7e9a8bcb
parentd1149a69c6121025816d388fadc3861e7407c594 (diff)
downloadbread-board-declare-06f919c57dfc917e50e6858100cfbe3a1b57a1be.tar.gz
bread-board-declare-06f919c57dfc917e50e6858100cfbe3a1b57a1be.zip
make sure i'm testing immutability too
-rw-r--r--t/01-basic.t6
-rw-r--r--t/02-deps.t8
-rw-r--r--t/03-lifecycle.t8
-rw-r--r--t/04-block.t5
-rw-r--r--t/10-inlining.t2
-rw-r--r--t/30-type-checks.t5
-rw-r--r--t/31-auto-deref.t3
-rw-r--r--t/33-constructor-name.t5
8 files changed, 29 insertions, 13 deletions
diff --git a/t/01-basic.t b/t/01-basic.t
index a679a47..c59a429 100644
--- a/t/01-basic.t
+++ b/t/01-basic.t
@@ -2,12 +2,14 @@
use strict;
use warnings;
use Test::More;
+use Test::Moose;
{
package Baz;
use Moose;
}
+my $i;
{
package Foo;
use Moose;
@@ -31,7 +33,6 @@ use Test::More;
class => 'Baz',
);
- my $i = 0;
has quux => (
is => 'ro',
isa => 'Str',
@@ -39,6 +40,8 @@ use Test::More;
);
}
+with_immutable {
+$i = 0;
{
my $foo = Foo->new;
ok($foo->has_service($_), "has service $_")
@@ -75,5 +78,6 @@ use Test::More;
is($foo->quux, 'XUUQ', "constructor overrides block injections");
is($foo->quux, 'XUUQ', "and returns the same thing each time");
}
+} 'Foo';
done_testing;
diff --git a/t/02-deps.t b/t/02-deps.t
index 73b3d4a..4b1143a 100644
--- a/t/02-deps.t
+++ b/t/02-deps.t
@@ -2,6 +2,7 @@
use strict;
use warnings;
use Test::More;
+use Test::Moose;
{
package Baz;
@@ -14,12 +15,12 @@ use Test::More;
);
}
+my $i;
{
package Foo;
use Moose;
use MooseX::Bread::Board;
- my $i = 0;
has bar => (
is => 'ro',
isa => 'Str',
@@ -34,12 +35,13 @@ use Test::More;
);
}
-{
+with_immutable {
+ $i = 0;
my $foo = Foo->new;
my $baz = $foo->baz;
is($baz->bar, '0', "deps resolved correctly");
is($baz->bar, '0', "doesn't re-resolve, since Baz is a normal class");
is($foo->baz->bar, '1', "re-resolves since the baz attr isn't a singleton");
-}
+} 'Foo';
done_testing;
diff --git a/t/03-lifecycle.t b/t/03-lifecycle.t
index aedf96c..8308e59 100644
--- a/t/03-lifecycle.t
+++ b/t/03-lifecycle.t
@@ -2,6 +2,7 @@
use strict;
use warnings;
use Test::More;
+use Test::Moose;
{
package Baz;
@@ -14,12 +15,12 @@ use Test::More;
);
}
+my $i;
{
package Foo;
use Moose;
use MooseX::Bread::Board;
- my $i = 0;
has bar => (
is => 'ro',
isa => 'Str',
@@ -35,7 +36,8 @@ use Test::More;
);
}
-{
+with_immutable {
+ $i = 0;
my $foo = Foo->new;
my $baz = $foo->baz;
is($baz->bar, '0', "deps resolved correctly");
@@ -44,6 +46,6 @@ use Test::More;
"doesn't re-resolve since the baz attr is a singleton");
is($foo->baz, $foo->baz,
"doesn't re-resolve since the baz attr is a singleton");
-}
+} 'Foo';
done_testing;
diff --git a/t/04-block.t b/t/04-block.t
index c0f9bad..3d31d6d 100644
--- a/t/04-block.t
+++ b/t/04-block.t
@@ -2,6 +2,7 @@
use strict;
use warnings;
use Test::More;
+use Test::Moose;
{
package Foo;
@@ -31,9 +32,9 @@ use Test::More;
);
}
-{
+with_immutable {
my $foo = Foo->new;
is($foo->baz, 'BARFOO', "self is passed properly");
-}
+} 'Foo';
done_testing;
diff --git a/t/10-inlining.t b/t/10-inlining.t
index 658d42d..091e7c6 100644
--- a/t/10-inlining.t
+++ b/t/10-inlining.t
@@ -136,6 +136,8 @@ use Test::More;
number_div => 'div',
},
);
+
+ __PACKAGE__->meta->make_immutable;
}
pass("everything compiled successfully");
diff --git a/t/30-type-checks.t b/t/30-type-checks.t
index 58f4405..bca6134 100644
--- a/t/30-type-checks.t
+++ b/t/30-type-checks.t
@@ -3,6 +3,7 @@ use strict;
use warnings;
use Test::More;
use Test::Fatal;
+use Test::Moose;
{
package Foo;
@@ -16,11 +17,11 @@ use Test::Fatal;
);
}
-{
+with_immutable {
my $foo = Foo->new;
like(exception { $foo->foo },
qr/^Attribute \(foo\) does not pass the type constraint because: Validation failed for 'Ref' with value FOO/,
"error when service returns invalid value");
-}
+} 'Foo';
done_testing;
diff --git a/t/31-auto-deref.t b/t/31-auto-deref.t
index c86fffd..57719b8 100644
--- a/t/31-auto-deref.t
+++ b/t/31-auto-deref.t
@@ -2,6 +2,7 @@
use strict;
use warnings;
use Test::More;
+use Test::Moose;
{
package Foo;
@@ -23,6 +24,7 @@ use Test::More;
);
}
+with_immutable {
{
my $foo = Foo->new;
@@ -40,5 +42,6 @@ use Test::More;
is_deeply(scalar($foo->bar), {'foo', 'bar'}, "scalar hash");
is_deeply({$foo->foo}, {'foo', 'bar'}, "list hash");
}
+} 'Foo';
done_testing;
diff --git a/t/33-constructor-name.t b/t/33-constructor-name.t
index 28647ee..ef46338 100644
--- a/t/33-constructor-name.t
+++ b/t/33-constructor-name.t
@@ -2,6 +2,7 @@
use strict;
use warnings;
use Test::More;
+use Test::Moose;
{
package Bar;
@@ -22,9 +23,9 @@ use Test::More;
);
}
-{
+with_immutable {
my $foo = Foo->new;
isa_ok($foo->bar, 'Bar');
-}
+} 'Foo';
done_testing;