]> git.vpit.fr Git - perl/modules/Lexical-Types.git/blobdiff - t/30-threads.t
Use a pointer table allocated on shared memory
[perl/modules/Lexical-Types.git] / t / 30-threads.t
index d3dcc3b644b8d29d471bf1ca123681635df70002..5c4b8d1710a3f587a552b6f3e1d8dfa404bf3edc 100644 (file)
@@ -15,12 +15,20 @@ BEGIN {
 
 use threads;
 
-use Test::More tests => 10 * 2;
+use Test::More tests => 10 * 2 * 2 * (1 + 2);
 
 {
  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 +36,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 $@;
  }
 }