From 1279ccc9e428866638d87ab91d4c5844241d5b48 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 24 Mar 2011 13:57:27 -0500 Subject: also need to check attribute type constraints during dep resolution --- t/30-type-checks.t | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 't') 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; -- cgit v1.2.3