[Bps-public-commit] r14885 - in Class-Require/trunk: lib/Class t

sartak at bestpractical.com sartak at bestpractical.com
Wed Aug 6 20:57:08 EDT 2008


Author: sartak
Date: Wed Aug  6 20:57:07 2008
New Revision: 14885

Modified:
   Class-Require/trunk/   (props changed)
   Class-Require/trunk/lib/Class/Require.pm
   Class-Require/trunk/t/001-is-class-loaded.t

Log:
 r68919 at onn:  sartak | 2008-08-06 20:27:06 -0400
 Check for methods, (failing) tests for ONLY @ISA and $VERSION


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:57:07 2008
@@ -38,6 +38,10 @@
     # ..such as $VERSION?
     return 1 if exists $table->{VERSION};
 
+    for my $glob (values %$table) {
+        return 1 if *{$glob}{CODE};
+    }
+
     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:57:07 2008
@@ -1,34 +1,55 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 6;
+use Test::More tests => 8;
 
 use Class::Require 'is_class_loaded';
 
+# basic {{{
 ok(is_class_loaded('Class::Require'), "Class::Require is loaded");
 ok(!is_class_loaded('Class::Require::NONEXISTENT'), "nonexistent class is NOT loaded");
+# }}}
 
+# @ISA (yes) {{{
 do {
     package Class::Require::WithISA;
     our @ISA = 'Class::Require';
 };
 ok(is_class_loaded('Class::Require::WithISA'), "class that defines \@ISA is loaded");
-
+# }}}
+# $ISA (no) {{{
 do {
-    package Class::Require::WithMethodISA;
-    sub ISA { 'Class::Require' }
+    package Class::Require::WithScalarISA;
+    our $ISA = 'Class::Require';
 };
-ok(is_class_loaded('Class::Require::WithMethodISA'), "class that defines a method ISA is loaded (no point in requiring it to be \@ISA)");
-
+ok(!is_class_loaded('Class::Require::WithScalarISA'), "class that defines \$ISA is not loaded");
+# }}}
+# $VERSION (yes) {{{
 do {
     package Class::Require::WithVERSION;
     our $VERSION = '1.0';
 };
 ok(is_class_loaded('Class::Require::WithVERSION'), "class that defines \$VERSION is loaded");
-
+# }}}
+# @VERSION (no) {{{
+do {
+    package Class::Require::WithArrayVERSION;
+    our @VERSION = "1.0";
+};
+ok(!is_class_loaded('Class::Require::WithArrayVERSION'), "class that defines \@VERSION is not loaded");
+# }}}
+# method (yes) {{{
+do {
+    package Class::Require::WithMethod;
+    sub foo { }
+};
+ok(is_class_loaded('Class::Require::WithMethod'), "class that defines any method is loaded");
+# }}}
+# global scalar (no) {{{
 do {
-    package Class::Require::WithMethodVERSION;
-    sub VERSION { '1.0' }
+    package Class::Require::WithScalar;
+    our $FOO = 1;
 };
-ok(is_class_loaded('Class::Require::WithMethodVERSION'), "class that defines a method VERSION is loaded (no point in requiring it to be \$VERSION)");
+ok(!is_class_loaded('Class::Require::WithScalar'), "class that defines just a scalar is not loaded");
+# }}}
 



More information about the Bps-public-commit mailing list