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