7 use VPIT::TestHelpers (
8 threads => [ 'indirect' => 'indirect::I_THREADSAFE()' ],
12 use Test::Leaner tests => 3;
15 skip 'Fails on 5.8.2 and lower' => 1 if "$]" <= 5.008_002;
17 my $status = run_perl <<' RUN';
18 my ($code, @expected);
23 sub cb { --$code if $_[0] eq shift(@expected) || q{DUMMY} }
25 $code = threads->create(sub {
26 eval q{return; no indirect hook => \&cb; new X;};
30 eval q{return; no indirect hook => \&cb; new Z;};
33 skip RUN_PERL_FAILED() => 1 unless defined $status;
35 'loading the pragma in a thread and using it outside doesn\'t segfault';
39 my $status = run_perl <<' RUN';
41 BEGIN { require indirect; }
42 sub X2::DESTROY { eval 'no indirect; 1'; exit 1 if $@ }
44 my $x = bless { }, 'X2';
50 skip RUN_PERL_FAILED() => 1 unless defined $status;
51 is $status, 0, 'indirect can be loaded in eval STRING during global destruction at the end of a thread';
55 my $status = run_perl <<' RUN';
60 no indirect hook => sub { lock $code; ++$code };
61 sub X3::DESTROY { eval $_[0]->{code} }
63 my $x = bless { code => 'new Z3' }, 'X3';
69 skip RUN_PERL_FAILED() => 1 unless defined $status;
70 my $code = $status >> 8;
71 is $code, 1, 'indirect checks eval STRING during global destruction at the end of a cloned thread';