From: Shawn M Moore Date: Tue, 10 Jun 2008 04:34:10 +0000 (+0000) Subject: Some ClassName simplification and fixes X-Git-Tag: 0.04~48 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7ecc21230bd017cdb82e6163b4053ac286ea1273;p=gitmo%2FMouse.git Some ClassName simplification and fixes --- diff --git a/lib/Mouse.pm b/lib/Mouse.pm index 3136d35..bfe4be7 100644 --- a/lib/Mouse.pm +++ b/lib/Mouse.pm @@ -98,6 +98,8 @@ sub load_class { sub is_class_loaded { my $class = shift; + return 0 if ref($class) || !defined($class) || !length($class); + no strict 'refs'; return 1 if defined ${"${class}::VERSION"} || defined @{"${class}::ISA"}; foreach my $symbol (keys %{"${class}::"}) { diff --git a/t/025-more-isa.t b/t/025-more-isa.t index 132d57f..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 => 29; +use Test::More tests => 23; use Test::Exception; do { @@ -61,26 +61,20 @@ lives_ok { do { package A; - our @VERSION; + our $VERSION = 1; package B; - our $VERSION = 1; + our @ISA = 'Mouse::Object'; package C; - our %ISA; + sub foo {} - package D; - our @ISA = 'Mouse::Object'; + package D::Child; + sub bar {} package E; - sub foo {} package F; - - package G::H; - sub bar {} - - package I; our $NOT_CODE = 1; }; @@ -94,7 +88,7 @@ do { ); }; -for ('A'..'E', 'G::H') { +for ('A'..'C', 'D::Child') { lives_ok { ClassNameTests->new(class => $_); }; @@ -105,7 +99,7 @@ for ('A'..'E', 'G::H') { }; } -for ('F', 'G', 'I', 'Z') { +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 $_/;