From: Shawn M Moore Date: Sun, 9 Nov 2008 17:00:01 +0000 (+0000) Subject: Test that the type constraint is checked too X-Git-Tag: 0.05~80 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a4ea464f5016f15ee58d4074d1aeef5c9f9c46eb;p=gitmo%2FMooseX-Role-Parameterized.git Test that the type constraint is checked too --- diff --git a/t/003-apply.t b/t/003-apply.t index 989764b..925dc2b 100644 --- a/t/003-apply.t +++ b/t/003-apply.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 14; +use Test::More tests => 15; use Test::Exception; do { @@ -55,12 +55,6 @@ do { }; }; -throws_ok { - package MyClass::Error; - use Moose; - with 'MyRole::Storage'; -} qr/^Attribute \(format\) is required/; - do { package MyClass::Dumper; use Moose; @@ -119,6 +113,20 @@ do { can_ok('MyClass::Three' => qw(freeze_Dumper freeze_Storable thaw_Dumper thaw_Storable store dump)); +throws_ok { + package MyClass::Error::Required; + use Moose; + with 'MyRole::Storage'; +} qr/^Attribute \(format\) is required/; + +throws_ok { + package MyClass::Error::Invalid; + use Moose; + with 'MyRole::Storage' => { + format => 'YAML', + }; +} qr/^Attribute \(format\) does not pass the type constraint/; + sub cant_ok { local $Test::Builder::Level = $Test::Builder::Level + 1; my $instance = shift;