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..17\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"});
44 $ret = threads->new(\&dorecurse, @_);
52 my $t = threads->new(\&dorecurse, 6..10);
59 # test that sleep lets other thread run
60 my $t = threads->new(\&dorecurse, 1);
73 $ret = threads->new(\&islocked, shift);
77 my $t = threads->new(\&islocked, "ok 9\n", "ok 10\n");
85 my $same = sprintf( "%0.f", $testno);
86 return $testno eq $same;
90 my ($string, $string_end) = @_;
92 # Do the match, saving the output in appropriate variables
93 $string =~ /(.*)(is)(.*)/;
94 # Yield control, allowing the other thread to fill in the match variables
96 # Examine the match variable contents; on broken perls this fails
97 return $3 eq $string_end;
104 my $thr1 = threads->new(\&testsprintf, 11);
105 my $thr2 = threads->new(\&testsprintf, 12);
107 my $short = "This is a long string that goes on and on.";
108 my $shorte = " a long string that goes on and on.";
109 my $long = "This is short.";
110 my $longe = " short.";
111 my $foo = "This is bar bar bar.";
112 my $fooe = " bar bar bar.";
113 my $thr3 = new threads \&threaded, $short, $shorte;
114 my $thr4 = new threads \&threaded, $long, $longe;
115 my $thr5 = new threads \&testsprintf, 15;
116 my $thr6 = new threads \&testsprintf, 16;
117 my $thr7 = new threads \&threaded, $foo, $fooe;