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