X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F025-more-isa.t;h=f11dc2581a815522cb84937d8a67889cc963d241;hb=bf1340491e6b319464aafb33c00c272ce60857ba;hp=e68e0ec7f4cc5222ad323eb3580cd35eb6e54fc3;hpb=fb706f5c1e60ddafe873717be7209066d47b8998;p=gitmo%2FMouse.git diff --git a/t/025-more-isa.t b/t/025-more-isa.t index e68e0ec..f11dc25 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 => 10; +use Test::More tests => 23; use Test::Exception; do { @@ -57,3 +57,56 @@ lives_ok { Other->new(oops => 10); }; +# ClassName coverage tests + +do { + package A; + our $VERSION = 1; + + package B; + our @ISA = 'Mouse::Object'; + + package C; + sub foo {} + + package D::Child; + sub bar {} + + package E; + + package F; + our $NOT_CODE = 1; +}; + +do { + package ClassNameTests; + use Mouse; + + has class => ( + is => 'rw', + isa => 'ClassName', + ); +}; + +for ('A'..'C', 'D::Child') { + lives_ok { + ClassNameTests->new(class => $_); + }; + + lives_ok { + my $obj = ClassNameTests->new; + $obj->class($_); + }; +} + +for ('E'..'F', 'NonExistentClass') { + 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 $_/; +}; +