X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F81-threads-teardown.t;h=6fc843780f6281ab2792a76ce762c0dd2386f4f5;hb=0d7058280090c294f5fe0eb9ac5251816dd31d30;hp=c60e14f1aa1695f0d3c4b01b8b7dacd8c3913e45;hpb=4c22d853712b16da554eac5525819366b1dec494;p=perl%2Fmodules%2FLexical-Types.git diff --git a/t/81-threads-teardown.t b/t/81-threads-teardown.t index c60e14f..6fc8437 100644 --- a/t/81-threads-teardown.t +++ b/t/81-threads-teardown.t @@ -4,12 +4,14 @@ use strict; use warnings; use lib 't/lib'; -use VPIT::TestHelpers; -use Lexical::Types::TestThreads; +use VPIT::TestHelpers ( + threads => [ 'Lexical::Types' => 'Lexical::Types::LT_THREADSAFE()' ], + 'run_perl', +); -use Test::More tests => 1; +use Test::Leaner tests => 2; -{ +SKIP: { my $status = run_perl <<' RUN'; { package IntX; package IntY; package IntZ; } my ($code, @expected); @@ -30,5 +32,26 @@ use Test::More tests => 1; $code += 256 if $code < 0; exit $code; RUN + skip RUN_PERL_FAILED() => 1 unless defined $status; is $status, 0, 'loading the pragma in a thread and using it outside doesn\'t segfault'; } + +SKIP: { + my $status = run_perl <<' RUN'; + use threads; + BEGIN { require Lexical::Types; } + sub X::DESTROY { + my $res = eval 'use Lexical::Types; sub Z::TYPEDSCALAR { 123 } my Z $z'; + exit 1 if $@; + exit 2 if not defined $res or $res != 123; + } + threads->create(sub { + my $x = bless { }, 'X'; + $x->{self} = $x; + return; + })->join; + exit 0; + RUN + skip RUN_PERL_FAILED() => 1 unless defined $status; + is $status, 0, 'Lexical::Types can be loaded in eval STRING during global destruction at the end of a thread'; +}