| 1 |
root |
1.1 |
$|=1; |
| 2 |
root |
1.3 |
print "1..18\n"; |
| 3 |
root |
1.1 |
|
| 4 |
|
|
use Coro; |
| 5 |
|
|
use Coro::Cont; |
| 6 |
|
|
|
| 7 |
|
|
$test = 1; |
| 8 |
|
|
|
| 9 |
|
|
sub a1 : Coro { |
| 10 |
root |
1.2 |
my $cont = csub { |
| 11 |
root |
1.5 |
cede; |
| 12 |
|
|
yield $_*2; |
| 13 |
|
|
cede; |
| 14 |
|
|
yield $_*3; |
| 15 |
root |
1.1 |
}; |
| 16 |
|
|
my @arr = map &$cont, 1,2,3,4,5,6; |
| 17 |
|
|
for(2,6,6,12,10,18) { |
| 18 |
|
|
print (((shift @arr == $_) ? "ok " : "not ok "), $test++, "\n"); |
| 19 |
|
|
} |
| 20 |
|
|
$done++; |
| 21 |
root |
1.5 |
cede while 1; |
| 22 |
root |
1.1 |
} |
| 23 |
|
|
|
| 24 |
|
|
sub a2 : Coro { |
| 25 |
root |
1.2 |
my $cont = csub { |
| 26 |
root |
1.5 |
cede; |
| 27 |
|
|
yield $_*20; |
| 28 |
|
|
cede; |
| 29 |
|
|
yield $_*30; |
| 30 |
root |
1.1 |
}; |
| 31 |
|
|
my @arr = map &$cont, 1,2,3,4,5,6; |
| 32 |
|
|
for(20,60,60,120,100,180) { |
| 33 |
|
|
print (((shift @arr == $_) ? "ok " : "not ok "), $test++, "\n"); |
| 34 |
|
|
} |
| 35 |
|
|
$done++; |
| 36 |
root |
1.5 |
cede while 1; |
| 37 |
root |
1.1 |
} |
| 38 |
|
|
|
| 39 |
|
|
print "ok ", $test++, "\n"; |
| 40 |
|
|
|
| 41 |
|
|
$done = 0; |
| 42 |
|
|
|
| 43 |
root |
1.5 |
cede while $done < 2; |
| 44 |
root |
1.3 |
|
| 45 |
|
|
sub cont : Cont { |
| 46 |
root |
1.5 |
yield 2*shift; |
| 47 |
|
|
yield 3*shift; |
| 48 |
root |
1.3 |
} |
| 49 |
|
|
|
| 50 |
|
|
print cont(3) == 6 ? "ok " : "not ok ", $test++, "\n"; |
| 51 |
|
|
print cont(4) == 12 ? "ok " : "not ok ", $test++, "\n"; |
| 52 |
|
|
print cont(5) == 10 ? "ok " : "not ok ", $test++, "\n"; |
| 53 |
|
|
print cont(6) == 18 ? "ok " : "not ok ", $test++, "\n"; |
| 54 |
|
|
print cont(7) == 14 ? "ok " : "not ok ", $test++, "\n"; |
| 55 |
|
|
|
| 56 |
|
|
|
| 57 |
|
|
|
| 58 |
root |
1.2 |
|