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}::"}) {
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 29;
+use Test::More tests => 23;
use Test::Exception;
do {
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;
};
);
};
-for ('A'..'E', 'G::H') {
+for ('A'..'C', 'D::Child') {
lives_ok {
ClassNameTests->new(class => $_);
};
};
}
-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 $_/;