]> git.vpit.fr Git - perl/modules/autovivification.git/blob - t/51-threads-teardown.t
6e35ac9b0105c8ee09341170a1c962cedc5215f0
[perl/modules/autovivification.git] / t / 51-threads-teardown.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use lib 't/lib';
7 use VPIT::TestHelpers;
8 use autovivification::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 = 1 + 2 + 4;
18   use threads;
19   $code -= threads->create(sub {
20    eval q{no autovivification; my $x; my $y = $x->{foo}; $x};
21    return defined($x) ? 0 : 1;
22   })->join;
23   $code -= defined(eval q{my $x; my $y = $x->{foo}; $x}) ? 2 : 0;
24   $code -= defined(eval q{no autovivification; my $x; my $y = $x->{foo}; $x})
25            ? 0 : 4;
26   exit $code;
27  RUN
28  is $status, 0, 'loading the pragma in a thread and using it outside doesn\'t segfault';
29 }