1 | $|=1; | 1 | $|=1; |
---|---|---|---|
2 | print "1..6\n"; | 2 | print "1..13\n"; |
3 | 3 | ||
4 | use Coro; | 4 | use Coro; |
5 | 5 | ||
6 | sub p1 : Coro { | 6 | async { |
7 | print "ok 2\n"; | 7 | print "ok 2\n"; |
8 | } | 8 | }; |
9 | 9 | ||
10 | print "ok 1\n"; | 10 | print "ok 1\n"; |
11 | cede; | 11 | cede; |
12 | print "ok 3\n"; | 12 | print "ok 3\n"; |
13 | 13 | ||
14 | my $c1 = async { | 14 | my $c1 = async { |
15 | print "ok 5\n"; | 15 | print "ok 5\n"; |
16 | cede; | 16 | cede; |
17 | print "not ok 8\n";#d# | ||
17 | }; | 18 | }; |
18 | 19 | ||
19 | print $c1->ready ? "not " : "", "ok 4\n"; | 20 | print $c1->ready ? "not " : "", "ok 4\n"; |
20 | 21 | ||
21 | cede; | 22 | cede; |
22 | 23 | ||
23 | print "ok 6\n"; | 24 | print "ok 6\n"; |
24 | 25 | ||
26 | $c1->on_destroy (sub { | ||
27 | print "ok 7\n"; | ||
28 | }); | ||
29 | |||
30 | $c1->cancel; | ||
31 | |||
32 | print "ok 8\n"; | ||
33 | |||
34 | cede; cede; | ||
35 | |||
36 | print "ok 9\n"; | ||
37 | |||
38 | { | ||
39 | my $as1 = async { | ||
40 | print "not ok 10\n"; | ||
41 | }; | ||
42 | |||
43 | my $as2 = async { | ||
44 | print "ok 10\n"; | ||
45 | $as1->cancel; | ||
46 | }; | ||
47 | |||
48 | $as2->cede_to; | ||
49 | } | ||
50 | |||
51 | { | ||
52 | my $as1 = async { | ||
53 | print "not ok 11\n"; | ||
54 | }; | ||
55 | |||
56 | my $as2 = async { | ||
57 | print "ok 11\n"; | ||
58 | $as1->cancel; | ||
59 | cede; | ||
60 | print "ok 12\n"; | ||
61 | $Coro::main->ready; | ||
62 | $Coro::main->throw ("exit"); | ||
63 | }; | ||
64 | |||
65 | local $SIG{__DIE__} = sub { | ||
66 | print "ok 13\n"; | ||
67 | exit if $@ eq "exit"; | ||
68 | }; | ||
69 | |||
70 | $as2->schedule_to; | ||
71 | } | ||
72 | |||
73 | print "not ok 12\n"; | ||
74 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |