8 use autovivification::TestThreads;
10 use Test::Leaner tests => 2;
14 skip 'Fails on 5.8.2 and lower' => 1 if "$]" <= 5.008_002;
16 my $status = run_perl <<' RUN';
19 $code -= threads->create(sub {
20 eval q{no autovivification; my $x; my $y = $x->{foo}; $x};
21 return defined($x) ? 0 : 1;
23 $code -= defined(eval q{my $x; my $y = $x->{foo}; $x}) ? 2 : 0;
24 $code -= defined(eval q{no autovivification; my $x; my $y = $x->{foo}; $x})
28 is $status, 0, 'loading the pragma in a thread and using it outside doesn\'t segfault';
32 my $status = run_perl <<' RUN';
34 BEGIN { require autovivification; }
36 eval 'no autovivification; my $x; my $y = $x->{foo}{bar}; use autovivification; my $z = $x->{a}{b}{c};';
40 my $x = bless { }, 'X';
46 is $status, 0, 'autovivification can be loaded in eval STRING during global destruction at the end of a thread';