Upgrade to Encode 2.16
[p5sagit/p5-mst-13.2.git] / ext / threads / t / stress_cv.t
CommitLineData
0f1612a7 1use strict;
2use warnings;
3
3dbf27b4 4BEGIN {
0f1612a7 5 if ($ENV{'PERL_CORE'}){
6 chdir 't';
7 unshift @INC, '../lib';
8 }
9 use Config;
3dbf27b4 10 unless ($Config{'useithreads'}) {
11 print "1..0 # Skip: no useithreads\n";
12 exit 0;
13 }
14}
15
16use ExtUtils::testlib;
0f1612a7 17
3dbf27b4 18BEGIN { print "1..64\n" };
19use threads;
20
21
22print "ok 1\n";
23
24
25
26
27sub ok {
28 my ($id, $ok, $name) = @_;
29
30 # You have to do it this way or VMS will get confused.
31 print $ok ? "ok $id - $name\n" : "not ok $id - $name\n";
32
33 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
34
35 return $ok;
36}
37
38
39ok(2,1,"");
40
41
42my @threads;
43for(3..33) {
44 ok($_,1,"Multiple thread test");
45 push @threads ,threads->create(sub { my $i = shift; for(1..500000) { $i++}},$_);
46}
47
48my $i = 34;
49for(@threads) {
50 $_->join;
51 ok($i++,1,"Thread joined");
52}
53