6 BEGIN { require indirect; }
9 use VPIT::TestHelpers (
10 threads => [ 'indirect' => indirect::I_THREADSAFE ],
13 use Test::Leaner tests => 3;
17 skip 'Fails on 5.8.2 and lower' => 1 if "$]" <= 5.008_002;
19 my $status = run_perl <<' RUN';
20 my ($code, @expected);
25 sub cb { --$code if $_[0] eq shift(@expected) || q{DUMMY} }
27 $code = threads->create(sub {
28 eval q{return; no indirect hook => \&cb; new X;};
32 eval q{return; no indirect hook => \&cb; new Z;};
35 is $status, 0, '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 X::DESTROY { eval 'no indirect; 1'; exit 1 if $@ }
44 my $x = bless { }, 'X';
50 is $status, 0, 'indirect can be loaded in eval STRING during global destruction at the end of a thread';
54 my $status = run_perl <<' RUN';
59 no indirect cb => sub { lock $code; ++$code };
60 sub X::DESTROY { eval $_[0]->{code} }
62 my $x = bless { code => 'new Z' }, 'X';
68 is $status, 0, 'indirect does not check eval STRING during global destruction at the end of a thread';