X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F30-threads.t;h=c3db6c15c8c21fb94eab99524ea35ac6e6c0a1f4;hb=5c21bf6de3e2527b0fe556b5d67d785f1d686a8d;hp=d3dcc3b644b8d29d471bf1ca123681635df70002;hpb=06cb3f3506161a118dc440264dcabcd612b9432c;p=perl%2Fmodules%2FLexical-Types.git diff --git a/t/30-threads.t b/t/30-threads.t index d3dcc3b..c3db6c1 100644 --- a/t/30-threads.t +++ b/t/30-threads.t @@ -15,12 +15,22 @@ BEGIN { use threads; -use Test::More tests => 10 * 2; +use Test::More tests => 10 * 2 * 2 * (1 + 2); + +defined and diag "Using threads $_" for $threads::VERSION; { package Lexical::Types::Test::Tag; - sub TYPEDSCALAR { $_[1] = threads->tid() } + sub TYPEDSCALAR { + my $tid = threads->tid(); + my ($file, $line) = (caller(0))[1, 2]; + my $where = "at $file line $line in thread $tid"; + Test::More::is($_[0], __PACKAGE__, "base type is correct $where"); + Test::More::is($_[2], 'Tag', "original type is correct $where"); + $_[1] = $tid; + (); + } } { package Tag; } @@ -28,10 +38,18 @@ use Test::More tests => 10 * 2; use Lexical::Types as => 'Lexical::Types::Test::'; sub try { + my $tid = threads->tid(); + for (1 .. 2) { my Tag $t; - my $tid = threads->tid(); is $t, $tid, "typed lexical correctly initialized at run $_ in thread $tid"; + + eval <<'EVALD'; + use Lexical::Types as => "Lexical::Types::Test::"; + my Tag $t2; + is $t2, $tid, "typed lexical correctly initialized in eval at run $_ in thread $tid"; +EVALD + diag $@ if $@; } }