summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
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;