summaryrefslogtreecommitdiff
path: root/ext/XS-APItest/t
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-10-19 22:37:37 +0100
committerDavid Mitchell <davem@iabyn.com>2010-10-19 23:29:25 +0100
commit9c540340879062c71c21eaf596d6df60630d5bb2 (patch)
tree69cb2468b54e645ab0dc720c6ff1fa95e4ff22d7 /ext/XS-APItest/t
parent557af69b54d1d713b9c1c375b3485b6ee43970ec (diff)
downloadperl-9c540340879062c71c21eaf596d6df60630d5bb2.tar.gz
add skeleton testing for the MULTICALL macros
The macros dMULTICALL, PUSH_MULTICALL, MULTICALL and POP_MULTICALL are completely untested in core apart from incidentally in List-Util. The exercise they get there is probably quite comprehensive, but it's not explicitly testing the macros themselves. Add a hook and new test file to XS::APItest specifically for this purpose. Currently the test file is almost empty. The multicall_each function is shamelessly stolen from List:;Util::first.
Diffstat (limited to 'ext/XS-APItest/t')
-rw-r--r--ext/XS-APItest/t/multicall.t24
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/XS-APItest/t/multicall.t b/ext/XS-APItest/t/multicall.t
new file mode 100644
index 0000000000..4a860477d1
--- /dev/null
+++ b/ext/XS-APItest/t/multicall.t
@@ -0,0 +1,24 @@
+#!perl -w
+
+# test the MULTICALL macros
+# Note: as of Oct 2010, there are not yet comprehensive tests
+# for these macros.
+
+use warnings;
+use strict;
+
+use Test::More tests => 4;
+use XS::APItest;
+
+
+{
+ my $sum = 0;
+ sub add { $sum += $_++ }
+
+ my @a = (1..3);
+ XS::APItest::multicall_each \&add, @a;
+ is($sum, 6, "sum okay");
+ is($a[0], 2, "a[0] okay");
+ is($a[1], 3, "a[1] okay");
+ is($a[2], 4, "a[2] okay");
+}