TODO test showing differences between xs and pp versions of Class::MOP::is_class_loaded
Tomas Doran [Mon, 12 Jan 2009 17:31:58 +0000 (17:31 +0000)]
Changes
t/306_is_class_loaded.t [new file with mode: 0644]
t/lib/TestClassLoaded.pm [new file with mode: 0644]

diff --git a/Changes b/Changes
index cdc8a24..8d18dce 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Perl extension Class-MOP.
 
+    * Tests
+      - Add test showing how the xs Class::MOP::is_class_loaded can
+        be made to operate differently to the pure perl version (t0m)
+
 0.75 Wed, December 31, 2008
     * Class::MOP::Class
       - A class that was made immutable and then mutable could end up
diff --git a/t/306_is_class_loaded.t b/t/306_is_class_loaded.t
new file mode 100644 (file)
index 0000000..38ca6a1
--- /dev/null
@@ -0,0 +1,25 @@
+use strict;
+use warnings;
+use FindBin qw/$Bin/;
+use lib "$Bin/lib";
+
+use Test::More tests => 1;
+use Class::MOP ();
+
+# Just defining this sub appears to shit in TestClassLoaded's symbol
+# tables (see the SCALAR package symbol you end up with).
+# This confuses the XS is_class_loaded method, which looks for _any_
+# symbol, not just code symbols of VERSION/AUTHORITY etc.
+
+sub fnar {
+    TestClassLoaded::this_method_does_not_even_exist()
+}
+
+Class::MOP::load_class('TestClassLoaded');
+
+TODO: {
+    local $TODO = 'Borked';
+    ok(TestClassLoaded->can('a_method'), 
+        'TestClassLoader::LoadedByLoader::a_method is defined');
+}
+
diff --git a/t/lib/TestClassLoaded.pm b/t/lib/TestClassLoaded.pm
new file mode 100644 (file)
index 0000000..8e89f10
--- /dev/null
@@ -0,0 +1,8 @@
+package TestClassLoaded;
+use strict;
+use warnings;
+
+sub a_method { 'a_method' }
+
+1;
+