5 require Config; import Config;
6 unless ($Config{'useithreads'}) {
7 print "1..0 # Skip: no useithreads\n";
13 use ExtUtils::testlib;
15 BEGIN { $| = 1; print "1..21\n" };
26 my $t = threads->new(\&content, "ok 2\n", "ok 3\n", 1..1000);
34 $t = threads->new(sub { lock($lock); print "ok 5\n"});
45 $ret = threads->new(\&dorecurse, @_);
50 my $t = threads->new(\&dorecurse, map { "ok $_\n" } 6..10);
55 # test that sleep lets other thread run
56 my $t = threads->new(\&dorecurse, "ok 11\n");
69 $ret = threads->new(\&islocked, shift);
73 my $t = threads->new(\&islocked, "ok 13\n", "ok 14\n");
81 my $same = sprintf( "%0.f", $testno);
82 return $testno eq $same;
86 my ($string, $string_end) = @_;
88 # Do the match, saving the output in appropriate variables
89 $string =~ /(.*)(is)(.*)/;
90 # Yield control, allowing the other thread to fill in the match variables
92 # Examine the match variable contents; on broken perls this fails
93 return $3 eq $string_end;
100 my $thr1 = threads->new(\&testsprintf, 15);
101 my $thr2 = threads->new(\&testsprintf, 16);
103 my $short = "This is a long string that goes on and on.";
104 my $shorte = " a long string that goes on and on.";
105 my $long = "This is short.";
106 my $longe = " short.";
107 my $foo = "This is bar bar bar.";
108 my $fooe = " bar bar bar.";
109 my $thr3 = new threads \&threaded, $short, $shorte;
110 my $thr4 = new threads \&threaded, $long, $longe;
111 my $thr5 = new threads \&testsprintf, 19;
112 my $thr6 = new threads \&testsprintf, 20;
113 my $thr7 = new threads \&threaded, $foo, $fooe;