Test that call checkers are copied with actual closures.
authorNicholas Clark <nick@ccl4.org>
Wed, 13 Feb 2013 14:11:16 +0000 (15:11 +0100)
committerNicholas Clark <nick@ccl4.org>
Wed, 13 Feb 2013 14:11:16 +0000 (15:11 +0100)
This relates to the tests added by commit 09fb282d08ec6c01.

ext/XS-APItest/t/call_checker.t

index b01323a..377cb74 100644 (file)
@@ -1,6 +1,6 @@
 use warnings;
 use strict;
-use Test::More tests => 70;
+use Test::More tests => 76;
 
 use XS::APItest;
 
@@ -178,4 +178,32 @@ is $@, "";
 is_deeply $foo_got, [ 2, qw(a b c) ], 'undef clears call checkers';
 is $foo_ret, "z";
 
+my %got;
+
+sub g {
+    my $name = shift;
+    my $sub = sub ($\@) {
+       $got{$name} = [ @_ ];
+       return $name;
+    };
+    cv_set_call_checker_scalars($sub);
+    return $sub;
+}
+
+BEGIN {
+    *whack = g("whack");
+    *glurp = g("glurp");
+}
+
+%got = ();
+my $whack_ret = whack(@b, @c);
+is $@, "";
+is_deeply $got{whack}, [ 2, 3 ];
+is $whack_ret, "whack";
+
+my $glurp_ret = glurp(@b, @c);
+is $@, "";
+is_deeply $got{glurp}, [ 2, 3 ];
+is $glurp_ret, "glurp";
+
 1;