summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-03-24 13:57:27 -0500
committerJesse Luehrs <doy@tozt.net>2011-03-24 13:57:27 -0500
commit1279ccc9e428866638d87ab91d4c5844241d5b48 (patch)
tree044283ba5f6e0bd64e7d17e395fb011ede9ab038 /t
parent990c3c03a657a5e42d667d854d75c260c889df00 (diff)
downloadbread-board-declare-1279ccc9e428866638d87ab91d4c5844241d5b48.tar.gz
bread-board-declare-1279ccc9e428866638d87ab91d4c5844241d5b48.zip
also need to check attribute type constraints during dep resolution
Diffstat (limited to 't')
-rw-r--r--t/30-type-checks.t19
1 files changed, 19 insertions, 0 deletions
diff --git a/t/30-type-checks.t b/t/30-type-checks.t
index 9133da3..b7718ac 100644
--- a/t/30-type-checks.t
+++ b/t/30-type-checks.t
@@ -15,6 +15,19 @@ use Test::Moose;
isa => 'Ref',
value => 'FOO',
);
+
+ has bar => (
+ is => 'ro',
+ isa => 'Str',
+ block => sub { {} },
+ );
+
+ has baz => (
+ is => 'ro',
+ isa => 'HashRef',
+ block => sub { shift->param('bar') },
+ dependencies => ['bar'],
+ );
}
with_immutable {
@@ -22,6 +35,12 @@ with_immutable {
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");
+ like(exception { $foo->bar },
+ qr/^Attribute \(bar\) does not pass the type constraint because: Validation failed for 'Str' with value HASH/,
+ "error when service returns invalid value");
+ like(exception { $foo->baz },
+ qr/^Attribute \(bar\) does not pass the type constraint because: Validation failed for 'Str' with value HASH/,
+ "error when service returns invalid value, even as a dependency");
} 'Foo';
done_testing;