8 use indirect::TestThreads;
10 use Test::Leaner tests => 3;
14 skip 'Fails on 5.8.2 and lower' => 1 if "$]" <= 5.008_002;
16 my $status = run_perl <<' RUN';
17 my ($code, @expected);
22 sub cb { --$code if $_[0] eq shift(@expected) || q{DUMMY} }
24 $code = threads->create(sub {
25 eval q{return; no indirect hook => \&cb; new X;};
29 eval q{return; no indirect hook => \&cb; new Z;};
32 is $status, 0, 'loading the pragma in a thread and using it outside doesn\'t segfault';
36 my $status = run_perl <<' RUN';
38 BEGIN { require indirect; }
39 sub X::DESTROY { eval 'no indirect; 1'; exit 1 if $@ }
41 my $x = bless { }, 'X';
47 is $status, 0, 'indirect can be loaded in eval STRING during global destruction at the end of a thread';
51 my $status = run_perl <<' RUN';
56 no indirect cb => sub { lock $code; ++$code };
57 sub X::DESTROY { eval $_[0]->{code} }
59 my $x = bless { code => 'new Z' }, 'X';
65 is $status, 0, 'indirect does not check eval STRING during global destruction at the end of a thread';