ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/t/03_cont.t
(Generate patch)

Comparing Coro/t/03_cont.t (file contents):
Revision 1.4 by root, Sat Jul 21 18:21:45 2001 UTC vs.
Revision 1.5 by root, Mon Jul 23 02:14:20 2001 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines