1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#!perl
use strict;
use warnings;
require "../../t/test.pl";
use XS::APItest;
# clone_with_stack creates a clone of the perl interpreter including
# the stack, then destroys the original interpreter and runs the
# remaining code using the new one.
# This is like doing a psuedo-fork and exiting the parent.
use Config;
if (not $Config{'useithreads'}) {
skip_all("clone_with_stack requires threads");
}
plan(4);
fresh_perl_is( <<'----', <<'====', undef, "minimal clone_with_stack" );
use XS::APItest;
clone_with_stack();
print "ok\n";
----
ok
====
fresh_perl_is( <<'----', <<'====', undef, "inside a subroutine" );
use XS::APItest;
sub f {
clone_with_stack();
}
f();
print "ok\n";
----
ok
====
{
local our $TODO = "clone_with_stack inside a begin block";
fresh_perl_is( <<'----', <<'====', undef, "inside a BEGIN block" );
use XS::APItest;
BEGIN {
clone_with_stack();
}
print "ok\n";
----
ok
====
}
{
fresh_perl_is( <<'----', <<'====', undef, "clone stack" );
use XS::APItest;
sub f {
clone_with_stack();
0..4;
}
print 'X-', 'Y-', join(':', f()), "-Z\n";
----
X-Y-0:1:2:3:4-Z
====
}
|