Upgrade to threads 1.75
[p5sagit/p5-mst-13.2.git] / dist / threads / t / libc.t
CommitLineData
0f1612a7 1use strict;
2use warnings;
83007387 3
4BEGIN {
2adbc9b6 5 require($ENV{PERL_CORE} ? '../../t/test.pl' : './t/test.pl');
f2cba68d 6
955c272e 7 use Config;
8 if (! $Config{'useithreads'}) {
9 skip_all(q/Perl not compiled with 'useithreads'/);
f2cba68d 10 }
11
955c272e 12 plan(11);
f2cba68d 13}
14
955c272e 15use ExtUtils::testlib;
83007387 16
955c272e 17use_ok('threads');
f2cba68d 18
fc04eb16 19### Start of Testing ###
20
83007387 21my $i = 10;
22my $y = 20000;
fc04eb16 23
83007387 24my %localtime;
955c272e 25for (1..$i) {
fc04eb16 26 $localtime{$_} = localtime($_);
83007387 27};
fc04eb16 28
83007387 29my @threads;
955c272e 30for (1..$i) {
31 $threads[$_] = threads->create(sub {
32 my $arg = shift;
33 my $localtime = $localtime{$arg};
34 my $error = 0;
35 for (1..$y) {
36 my $lt = localtime($arg);
37 if ($localtime ne $lt) {
38 $error++;
39 }
fc04eb16 40 }
955c272e 41 return $error;
42 }, $_);
83007387 43}
44
955c272e 45for (1..$i) {
46 is($threads[$_]->join(), 0, 'localtime() thread-safe');
83007387 47}
48
561ee912 49exit(0);
50
fc04eb16 51# EOF