This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
XS::APItest tests for XS_APIVERSION_BOOTCHECK.
authorNicholas Clark <nick@ccl4.org>
Fri, 8 Oct 2010 14:55:08 +0000 (15:55 +0100)
committerNicholas Clark <nick@ccl4.org>
Fri, 8 Oct 2010 15:58:10 +0000 (16:58 +0100)
ext/XS-APItest/APItest.xs
ext/XS-APItest/XSUB-redefined-macros.xs
ext/XS-APItest/t/xsub_h.t

index 7b3b10c..b59aff4 100644 (file)
@@ -607,6 +607,7 @@ static int my_keyword_plugin(pTHX_
 
 XS(XS_XS__APItest__XSUB_XS_VERSION_undef);
 XS(XS_XS__APItest__XSUB_XS_VERSION_empty);
+XS(XS_XS__APItest__XSUB_XS_APIVERSION_invalid);
 
 #include "const-c.inc"
 
@@ -621,6 +622,7 @@ MODULE = XS::APItest                PACKAGE = XS::APItest::XSUB
 BOOT:
     newXS("XS::APItest::XSUB::XS_VERSION_undef", XS_XS__APItest__XSUB_XS_VERSION_undef, __FILE__);
     newXS("XS::APItest::XSUB::XS_VERSION_empty", XS_XS__APItest__XSUB_XS_VERSION_empty, __FILE__);
+    newXS("XS::APItest::XSUB::XS_APIVERSION_invalid", XS_XS__APItest__XSUB_XS_APIVERSION_invalid, __FILE__);
 
 void
 XS_VERSION_defined(...)
@@ -628,6 +630,12 @@ XS_VERSION_defined(...)
         XS_VERSION_BOOTCHECK;
         XSRETURN_EMPTY;
 
+void
+XS_APIVERSION_valid(...)
+    PPCODE:
+        XS_APIVERSION_BOOTCHECK;
+        XSRETURN_EMPTY;
+
 MODULE = XS::APItest:Hash              PACKAGE = XS::APItest::Hash
 
 void
index afbe674..05cfb41 100644 (file)
@@ -5,6 +5,8 @@
 
 #undef XS_VERSION
 #define XS_VERSION ""
+#undef PERL_API_VERSION_STRING
+#define PERL_API_VERSION_STRING "1.0.16"
 #include "XSUB.h"
 
 /* This can't be "MODULE = XS::APItest" as then we get duplicate bootstraps.  */
@@ -17,3 +19,9 @@ XS_VERSION_empty(...)
     PPCODE:
         XS_VERSION_BOOTCHECK;
         XSRETURN_EMPTY;
+
+void
+XS_APIVERSION_invalid(...)
+    PPCODE:
+        XS_APIVERSION_BOOTCHECK;
+        XSRETURN_EMPTY;
index 8735552..93742b1 100644 (file)
@@ -114,4 +114,10 @@ foreach $XS_VERSION (undef, @versions) {
     is ($count, 0, "no objects exist");
 }
 
+is_deeply([XS_APIVERSION_valid("Pie")], [], "XS_APIVERSION_BOOTCHECK passes");
+is(eval {XS_APIVERSION_invalid("Pie"); 1}, undef,
+   "XS_APIVERSION_BOOTCHECK croaks for an invalid version");
+like($@, qr/Perl API version v1.0.16 of Pie does not match v5\.\d+\.\d+/,
+     "expected error");
+
 done_testing();