Debian Codegraph @

ext/XS-APItest/t/mortal_destructor.t

raw
1 use XS::APItest;
2 use Test::More tests => 1;
3 use Data::Dumper;
4 my $warnings = "";
5 $SIG{__WARN__} = sub { $warnings .= $_[0]; };
6
7 warn "Before test_mortal_destructor_sv\n";
8 test_mortal_destructor_sv(sub { warn "in perl callback: ", $_[0],"\n" }, {});
9 warn "After test_mortal_destructor_sv\n";
10
11 warn "Before test_mortal_destructor_av\n";
12 test_mortal_destructor_av(sub { warn "in perl callback: @_\n" }, ["a","b","c"]);
13 warn "After test_mortal_destructor_av\n";
14
15 warn "Before test_mortal_destructor_x\n";
16 test_mortal_svfunc_x("this is an argument");
17 warn "After test_mortal_destructor_x\n";
18
19 $warnings=~s/0x[A-Fa-f0-9]+/0xDEADBEEF/g;
20 is($warnings, <<'EXPECT');
21 Before test_mortal_destructor_sv
22 in perl callback: HASH(0xDEADBEEF)
23 After test_mortal_destructor_sv
24 Before test_mortal_destructor_av
25 in perl callback: a b c
26 After test_mortal_destructor_av
27 Before test_mortal_destructor_x
28 In destruct_test: this is an argument
29 After test_mortal_destructor_x
30 EXPECT