[Bps-public-commit] r14880 - in Class-Require/trunk: lib/Class t
sartak at bestpractical.com
sartak at bestpractical.com
Wed Aug 6 20:18:35 EDT 2008
Author: sartak
Date: Wed Aug 6 20:18:17 2008
New Revision: 14880
Modified:
Class-Require/trunk/ (props changed)
Class-Require/trunk/lib/Class/Require.pm
Class-Require/trunk/t/001-is-class-loaded.t
Log:
r68913 at onn: sartak | 2008-08-06 20:15:59 -0400
A module that defines @ISA is loaded
Modified: Class-Require/trunk/lib/Class/Require.pm
==============================================================================
--- Class-Require/trunk/lib/Class/Require.pm (original)
+++ Class-Require/trunk/lib/Class/Require.pm Wed Aug 6 20:18:17 2008
@@ -22,9 +22,19 @@
sub is_class_loaded {
my $class = shift;
+ # is the module's file in %INC?
my $file = (join '/', split '::', $class) . '.pm';
return 1 if $INC{$file};
+ # any interesting symbols in this module's symbol table?
+ my $table = do {
+ no strict 'refs';
+ \%{ $class . '::' };
+ };
+
+ # ..such as @ISA?
+ return 1 if exists $table->{ISA};
+
return 0;
}
Modified: Class-Require/trunk/t/001-is-class-loaded.t
==============================================================================
--- Class-Require/trunk/t/001-is-class-loaded.t (original)
+++ Class-Require/trunk/t/001-is-class-loaded.t Wed Aug 6 20:18:17 2008
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 2;
+use Test::More tests => 3;
use Class::Require 'is_class_loaded';
@@ -9,3 +9,10 @@
ok(!is_class_loaded('Class::Require::NONEXISTENT'), "nonexistent class is NOT loaded");
+do {
+ package Class::Require::WithISA;
+ our @ISA = 'Class::Require';
+};
+
+ok(is_class_loaded('Class::Require::WithISA'), "class that defines \@ISA is loaded");
+
More information about the Bps-public-commit
mailing list