3 # test the MULTICALL macros
4 # Note: as of Oct 2010, there are not yet comprehensive tests
10 use Test::More tests => 7;
16 sub add { $sum += $_++ }
19 XS::APItest::multicall_each \&add, @a;
20 is($sum, 6, "sum okay");
21 is($a[0], 2, "a[0] okay");
22 is($a[1], 3, "a[1] okay");
23 is($a[2], 4, "a[2] okay");
27 # multicall using a sub that aleady has CvDEPTH > 1 caused sub
28 # to be prematurely freed
32 sub REC::DESTROY { $destroyed = 1 }
41 XS::APItest::multicall_each \&$sub, 1,2,3;
46 is($destroyed, 0, "f not yet destroyed");
48 is($destroyed, 1, "f now destroyed");
53 # deep recursion realloced the CX stack, but the dMULTICALL local var
54 # 'cx' still pointed to the old one.
55 # Thius doesn;t actually test the failure (I couldn't think of a way to
56 # get the failure to show at the perl level) but it allows valgribnd or
57 # similar to spot any errors.
60 sub rec { my $c = shift; rec($c-1) if $c > 0 };
61 my @r = XS::APItest::multicall_each { rec(90) } 1,2,3;