]> git.vpit.fr Git - perl/modules/Lexical-Types.git/blob - t/30-threads.t
Initial import
[perl/modules/Lexical-Types.git] / t / 30-threads.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Config qw/%Config/;
7
8 BEGIN {
9  if (!$Config{useithreads}) {
10   require Test::More;
11   Test::More->import;
12   plan(skip_all => 'This perl wasn\'t built to support threads');
13  }
14 }
15
16 use threads;
17
18 use Test::More tests => 10 * 2;
19
20 {
21  package Lexical::Types::Test::Tag;
22
23  sub TYPEDSCALAR { $_[1] = threads->tid() }
24 }
25
26 { package Tag; }
27
28 use Lexical::Types as => 'Lexical::Types::Test::';
29
30 sub try {
31  for (1 .. 2) {
32   my Tag $t;
33   my $tid = threads->tid();
34   is $t, $tid, "typed lexical correctly initialized at run $_ in thread $tid";
35  }
36 }
37
38 my @t = map threads->create(\&try), 1 .. 10;
39 $_->join for @t;