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
1 use strict;
2 use warnings;
3
4 BEGIN {
5     if ($ENV{'PERL_CORE'}){
6         chdir 't';
7         unshift @INC, '../lib';
8     }
9
10     require($ENV{PERL_CORE} ? "./test.pl" : "./t/test.pl");
11
12     use Config;
13     if (! $Config{'useithreads'}) {
14         skip_all(q/Perl not compiled with 'useithreads'/);
15     }
16
17     plan(11);
18 }
19
20 use ExtUtils::testlib;
21
22 use_ok('threads');
23
24 ### Start of Testing ###
25
26 my $i = 10;
27 my $y = 20000;
28
29 my %localtime;
30 for (1..$i) {
31     $localtime{$_} = localtime($_);
32 };
33
34 my @threads;
35 for (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                             }
45                         }
46                         return $error;
47                     }, $_);
48 }
49
50 for (1..$i) {
51     is($threads[$_]->join(), 0, 'localtime() thread-safe');
52 }
53
54 # EOF