Tests for XS AUTOLOAD routines
authorFather Chrysostomos <sprout@cpan.org>
Sun, 9 Oct 2011 06:55:04 +0000 (23:55 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 10 Oct 2011 06:14:07 +0000 (23:14 -0700)
MANIFEST
ext/XS-APItest/APItest.pm
ext/XS-APItest/APItest.xs
ext/XS-APItest/t/autoload.t [new file with mode: 0644]

index 4cde7fb..00b95dd 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -3809,6 +3809,7 @@ ext/XS-APItest/notcore.c  Test API functions when PERL_CORE is not defined
 ext/XS-APItest/numeric.xs      XS::APItest wrappers for numeric.c
 ext/XS-APItest/README          XS::APItest extension
 ext/XS-APItest/t/arrayexpr.t   test recursive descent expression parsing
+ext/XS-APItest/t/autoload.t    Test XS AUTOLOAD routines
 ext/XS-APItest/t/BHK.pm                Helper for ./blockhooks.t
 ext/XS-APItest/t/blockasexpr.t test recursive descent block parsing
 ext/XS-APItest/t/blockhooks-csc.t      XS::APItest: more tests for PL_blockhooks
index a3792d4..c6426d3 100644 (file)
@@ -24,6 +24,8 @@ sub import {
            if ($sym_name =~ /::$/) {
                # Skip any subpackages that are clearly OO
                next if *{$glob}{HASH}{'new'};
+               # Skip AutoLoader, too, as it’s a special case
+               next if $sym_name eq 'AutoLoader::';
                push @stashes, "$stash_name$sym_name", *{$glob}{HASH};
            } elsif (ref $glob eq 'SCALAR' || *{$glob}{CODE}) {
                if ($exports) {
index 0f09c3a..96efeb4 100644 (file)
@@ -1517,6 +1517,16 @@ void
 ptr_table_clear(table)
 XS::APItest::PtrTable table
 
+MODULE = XS::APItest::AutoLoader       PACKAGE = XS::APItest::AutoLoader
+
+SV *
+AUTOLOAD()
+    CODE:
+       RETVAL = newSVpvn_flags(SvPVX(cv), SvCUR(cv), SvUTF8(cv));
+    OUTPUT:
+       RETVAL
+
+
 MODULE = XS::APItest           PACKAGE = XS::APItest
 
 PROTOTYPES: DISABLE
diff --git a/ext/XS-APItest/t/autoload.t b/ext/XS-APItest/t/autoload.t
new file mode 100644 (file)
index 0000000..dd89c50
--- /dev/null
@@ -0,0 +1,14 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+use XS::APItest;
+
+is XS::APItest::AutoLoader::frob(), 'frob', 'name passed to XS AUTOLOAD';
+is "XS::APItest::AutoLoader::fr\0b"->(), "fr\0b",
+  'name with embedded null passed to XS AUTOLOAD';
+is "XS::APItest::AutoLoader::fr\x{1ed9}b"->(), "fr\x{1ed9}b",
+  'Unicode name passed to XS AUTOLOAD';