]> git.vpit.fr Git - perl/modules/Lexical-Types.git/blobdiff - t/81-threads-teardown.t
Do nothing after that the thread local storage has been freed
[perl/modules/Lexical-Types.git] / t / 81-threads-teardown.t
index 741d2242e506b8216c4dd9b2ab716522298cf813..7a5c2270268a3df0b335a154fc532d4b3a872bb9 100644 (file)
@@ -4,20 +4,10 @@ use strict;
 use warnings;
 
 use lib 't/lib';
+use VPIT::TestHelpers;
 use Lexical::Types::TestThreads;
 
-use Test::More tests => 1;
-
-sub run_perl {
- my $code = shift;
-
- my ($SystemRoot, $PATH) = @ENV{qw<SystemRoot PATH>};
- local %ENV;
- $ENV{SystemRoot} = $SystemRoot if $^O eq 'MSWin32' and defined $SystemRoot;
- $ENV{PATH}       = $PATH       if $^O eq 'cygwin'  and defined $PATH;
-
- system { $^X } $^X, '-T', map("-I$_", @INC), '-e', $code;
-}
+use Test::More tests => 2;
 
 {
  my $status = run_perl <<' RUN';
@@ -42,3 +32,21 @@ sub run_perl {
  RUN
  is $status, 0, 'loading the pragma in a thread and using it outside doesn\'t segfault';
 }
+
+{
+ my $status = run_perl <<' RUN';
+  use threads;
+  BEGIN { require Lexical::Types; }
+  sub X::DESTROY {
+   eval 'use Lexical::Types; package Z; my Z $z = 1';
+   exit 1 if $@;
+  }
+  threads->create(sub {
+   my $x = bless { }, 'X';
+   $x->{self} = $x;
+   return;
+  })->join;
+  exit 0;
+ RUN
+ is $status, 0, 'Lexical::Types can be loaded in eval STRING during global destruction at the end of a thread';
+}