9 Test::More::plan(skip_all => $msg);
12 use Config qw<%Config>;
15 my $force = $ENV{PERL_AUTOVIVIFICATION_TEST_THREADS} ? 1 : !1;
16 skipall 'This perl wasn\'t built to support threads'
17 unless $Config{useithreads};
18 skipall 'perl 5.13.4 required to test thread safety'
19 unless $force or $] >= 5.013004;
27 require autovivification;
28 skipall 'This autovivification isn\'t thread safe'
29 unless autovivification::A_THREADSAFE();
31 defined and diag "Using threads $_" for $threads::VERSION;
37 my $SystemRoot = $ENV{SystemRoot};
39 $ENV{SystemRoot} = $SystemRoot if $^O eq 'MSWin32' and defined $SystemRoot;
41 system { $^X } $^X, '-T', map("-I$_", @INC), '-e', $code;
46 skip 'Fails on 5.8.2 and lower' => 1 if $] <= 5.008002;
48 my $status = run_perl <<' RUN';
51 $code -= threads->create(sub {
52 eval q{no autovivification; my $x; my $y = $x->{foo}; $x};
53 return defined($x) ? 0 : 1;
55 $code -= defined(eval q{my $x; my $y = $x->{foo}; $x}) ? 2 : 0;
56 $code -= defined(eval q{no autovivification; my $x; my $y = $x->{foo}; $x})
60 is $status, 0, 'loading the pragma in a thread and using it outside doesn\'t segfault';