From: Shawn M Moore Date: Tue, 10 Jun 2008 02:26:39 +0000 (+0000) Subject: Improve coverage of TypeRegistry X-Git-Tag: 0.04~69 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6feb83f15e8242426f088e25e4adb37a6d8698ad;p=gitmo%2FMouse.git Improve coverage of TypeRegistry --- diff --git a/lib/Mouse/TypeRegistry.pm b/lib/Mouse/TypeRegistry.pm index 9c18bd2..6568990 100644 --- a/lib/Mouse/TypeRegistry.pm +++ b/lib/Mouse/TypeRegistry.pm @@ -70,3 +70,18 @@ sub optimized_constraints { 1; +__END__ + +=head1 NAME + +Mouse::TypeRegistry - simple type constraints + +=head1 METHODS + +=head2 optimized_constraints -> HashRef[CODE] + +Returns the simple type constraints that Mouse understands. + +=cut + + diff --git a/t/025-more-isa.t b/t/025-more-isa.t index 213fba8..132d57f 100644 --- a/t/025-more-isa.t +++ b/t/025-more-isa.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 29; use Test::Exception; do { @@ -57,3 +57,62 @@ lives_ok { Other->new(oops => 10); }; +# ClassName coverage tests + +do { + package A; + our @VERSION; + + package B; + our $VERSION = 1; + + package C; + our %ISA; + + package D; + our @ISA = 'Mouse::Object'; + + package E; + sub foo {} + + package F; + + package G::H; + sub bar {} + + package I; + our $NOT_CODE = 1; +}; + +do { + package ClassNameTests; + use Mouse; + + has class => ( + is => 'rw', + isa => 'ClassName', + ); +}; + +for ('A'..'E', 'G::H') { + lives_ok { + ClassNameTests->new(class => $_); + }; + + lives_ok { + my $obj = ClassNameTests->new; + $obj->class($_); + }; +} + +for ('F', 'G', 'I', 'Z') { + throws_ok { + ClassNameTests->new(class => $_); + } qr/Attribute \(class\) does not pass the type constraint because: Validation failed for 'ClassName' failed with value $_/; + + throws_ok { + my $obj = ClassNameTests->new; + $obj->class($_); + } qr/Attribute \(class\) does not pass the type constraint because: Validation failed for 'ClassName' failed with value $_/; +}; +