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