5 require Config; import Config;
6 unless ($Config{'useithreads'}) {
7 print "1..0 # Skip: no useithreads\n";
12 use ExtUtils::testlib;
14 BEGIN { $| = 1; print "1..22\n" };
25 my $t = threads->new(\&content, "ok 2\n", "ok 3\n", 1..1000);
33 $t = threads->new(sub { lock($lock); print "ok 5\n"});
44 $ret = threads->new(\&dorecurse, @_);
49 my $t = threads->new(\&dorecurse, map { "ok $_\n" } 6..10);
54 # test that sleep lets other thread run
55 my $t = threads->new(\&dorecurse, "ok 11\n");
68 $ret = threads->new(\&islocked, shift);
72 my $t = threads->new(\&islocked, "ok 13\n", "ok 14\n");
80 my $same = sprintf( "%0.f", $testno);
81 if($testno eq $same) {
84 print "not ok $testno\t# '$testno' ne '$same'\n";
89 my ($string, $string_end, $testno) = @_;
91 # Do the match, saving the output in appropriate variables
92 $string =~ /(.*)(is)(.*)/;
93 # Yield control, allowing the other thread to fill in the match variables
95 # Examine the match variable contents; on broken perls this fails
96 if ($3 eq $string_end) {
102 # This is a 5005thread failure that should be gone in ithreads
106 print "not ok $testno # other thread filled in match variables\n";
112 my $thr1 = threads->new(\&testsprintf, 15);
113 my $thr2 = threads->new(\&testsprintf, 16);
115 my $short = "This is a long string that goes on and on.";
116 my $shorte = " a long string that goes on and on.";
117 my $long = "This is short.";
118 my $longe = " short.";
119 my $foo = "This is bar bar bar.";
120 my $fooe = " bar bar bar.";
121 my $thr3 = new threads \&threaded, $short, $shorte, "17";
122 my $thr4 = new threads \&threaded, $long, $longe, "18";
123 my $thr5 = new threads \&testsprintf, "19";
124 my $thr6 = threads->new(\&testsprintf, 20);
125 my $thr7 = new threads \&threaded, $foo, $fooe, "21";