]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/41-threads-teardown.t
42d4ae8e282151cbc4eb40db6c8fea8c24067b99
[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 indirect::TestThreads;
8
9 use Test::Leaner tests => 1;
10
11 sub run_perl {
12  my $code = shift;
13
14  my $SystemRoot   = $ENV{SystemRoot};
15  local %ENV;
16  $ENV{SystemRoot} = $SystemRoot if $^O eq 'MSWin32' and defined $SystemRoot;
17
18  system { $^X } $^X, '-T', map("-I$_", @INC), '-e', $code;
19 }
20
21 SKIP:
22 {
23  skip 'Fails on 5.8.2 and lower' => 1 if "$]" <= 5.008002;
24
25  my $status = run_perl <<' RUN';
26   my ($code, @expected);
27   BEGIN {
28    $code = 2;
29    @expected = qw<X Z>;
30   }
31   sub cb { --$code if $_[0] eq shift(@expected) || q{DUMMY} }
32   use threads;
33   $code = threads->create(sub {
34    eval q{return; no indirect hook => \&cb; new X;};
35    return $code;
36   })->join;
37   eval q{new Y;};
38   eval q{return; no indirect hook => \&cb; new Z;};
39   exit $code;
40  RUN
41  is $status, 0, 'loading the pragma in a thread and using it outside doesn\'t segfault';
42 }