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