]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/41-threads-teardown.t
Use run_perl() from VPIT::TestHelpers
[perl/modules/indirect.git] / t / 41-threads-teardown.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use lib 't/lib';
7 use VPIT::TestHelpers;
8 use indirect::TestThreads;
9
10 use Test::Leaner tests => 1;
11
12 SKIP:
13 {
14  skip 'Fails on 5.8.2 and lower' => 1 if "$]" <= 5.008_002;
15
16  my $status = run_perl <<' RUN';
17   my ($code, @expected);
18   BEGIN {
19    $code = 2;
20    @expected = qw<X Z>;
21   }
22   sub cb { --$code if $_[0] eq shift(@expected) || q{DUMMY} }
23   use threads;
24   $code = threads->create(sub {
25    eval q{return; no indirect hook => \&cb; new X;};
26    return $code;
27   })->join;
28   eval q{new Y;};
29   eval q{return; no indirect hook => \&cb; new Z;};
30   exit $code;
31  RUN
32  is $status, 0, 'loading the pragma in a thread and using it outside doesn\'t segfault';
33 }