9 Test::More::plan(skip_all => $msg);
12 use Config qw/%Config/;
15 my $force = $ENV{PERL_LEXICAL_TYPES_TEST_THREADS} ? 1 : !1;
16 skipall 'This perl wasn\'t built to support threads'
17 unless $Config{useithreads};
18 skipall 'perl 5.13.4 required to test thread safety'
19 unless $force or $] >= 5.013004;
27 require Lexical::Types;
28 skipall 'This Lexical::Types isn\'t thread safe'
29 unless Lexical::Types::LT_THREADSAFE();
30 plan tests => 10 * 2 * 3 * (1 + 2);
31 defined and diag "Using threads $_" for $threads::VERSION;
35 package Lexical::Types::Test::Tag;
38 my $tid = threads->tid();
39 my ($file, $line) = (caller(0))[1, 2];
40 my $where = "at $file line $line in thread $tid";
41 local $Test::Builder::Level = $Test::Builder::Level + 1;
42 Test::More::is($_[0], __PACKAGE__, "base type is correct $where");
43 Test::More::is($_[2], 'Tag', "original type is correct $where");
51 use Lexical::Types as => 'Lexical::Types::Test::';
54 my $tid = threads->tid();
58 is $t, $tid, "typed lexical correctly initialized at run $_ in thread $tid";
61 use Lexical::Types as => "Lexical::Types::Test::";
63 is $t2, $tid, "typed lexical correctly initialized in eval at run $_ in thread $tid";
69 skip 'Hints aren\'t propagated into eval STRING below perl 5.10' => 3
73 is $t3, $tid, "typed lexical correctly initialized in eval (propagated) at run $_ in thread $tid"
79 my @t = map threads->create(\&try), 1 .. 10;