3 # test per-interpeter static data API (MY_CXT)
8 push @INC, "::lib:$MacPerl::Architecture:" if $^O eq 'MacOS';
9 require Config; import Config;
10 if ($Config{'extensions'} !~ /\bXS\/APItest\b/) {
11 # Look, I'm using this fully-qualified variable more than once!
12 my $arch = $MacPerl::Architecture;
13 print "1..0 # Skip: XS::APItest was not built\n";
16 $threads = $Config{'useithreads'};
17 # must 'use threads' before 'use Test::More'
18 eval 'use threads' if $threads;
24 use Test::More tests => 16;
27 use_ok('XS::APItest');
30 is(my_cxt_getint(), 99, "initial int value");
31 is(my_cxt_getsv($_), "initial", "initial SV value$_")
32 foreach '', ' (context arg)';
35 is(my_cxt_getint(), 1234, "new int value");
38 is(my_cxt_getsv($_), "abcd", "new SV value$_")
39 foreach '', ' (context arg)';
42 is(my_cxt_getint(), 1234, "initial int value (child)");
44 is(my_cxt_getint(), 4321, "new int value (child)");
46 is(my_cxt_getsv($_), "initial_clone", "initial sv value (child)$_")
47 foreach '', ' (context arg)';
49 is(my_cxt_getsv($_), "dcba", "new SV value (child)$_")
50 foreach '', ' (context arg)';
54 skip "No threads", 6 unless $threads;
55 threads->create(\&do_thread)->join;
58 is(my_cxt_getint(), 1234, "int value preserved after join");
59 is(my_cxt_getsv($_), "abcd", "SV value preserved after join$_")
60 foreach '', ' (context arg)';