… | |
… | |
14 | } |
14 | } |
15 | } |
15 | } |
16 | |
16 | |
17 | use AnyEvent; |
17 | use AnyEvent; |
18 | use AnyEvent::Util; |
18 | use AnyEvent::Util; |
|
|
19 | |
|
|
20 | BEGIN { $ENV{PERL_ANYEVENT_LOOP_TESTS} or ((print qq{1..0 # SKIP PERL_ANYEVENT_LOOP_TESTS not true\n}), exit 0) } |
19 | BEGIN { eval q{use AnyEvent::Impl::Cocoa;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::Cocoa not loadable |
21 | BEGIN { eval q{use AnyEvent::Impl::Cocoa;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::Cocoa not loadable\n}), exit 0) } |
20 | }), exit 0) } |
22 | |
|
|
23 | |
21 | |
24 | |
22 | $| = 1; print "1..15\n"; |
25 | $| = 1; print "1..15\n"; |
23 | |
26 | |
24 | print "ok 1\n"; |
27 | print "ok 1\n"; |
25 | |
28 | |
… | |
… | |
40 | } |
43 | } |
41 | |
44 | |
42 | # I/O read |
45 | # I/O read |
43 | { |
46 | { |
44 | my $cv = AE::cv; |
47 | my $cv = AE::cv; |
45 | my $wt = AE::timer 0.1, 0, $cv; |
48 | my $wt = AE::timer 0.01, 0, $cv; |
46 | my $s = 0; |
49 | my $s = 0; |
47 | |
50 | |
48 | my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 }; |
51 | my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 }; |
49 | my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 }; |
52 | my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 }; |
50 | |
53 | |
… | |
… | |
65 | print $s == 3 ? "" : "not ", "ok 4 # $s\n"; |
68 | print $s == 3 ? "" : "not ", "ok 4 # $s\n"; |
66 | |
69 | |
67 | sysread $a, my $dummy, 1; |
70 | sysread $a, my $dummy, 1; |
68 | |
71 | |
69 | $cv = AE::cv; |
72 | $cv = AE::cv; |
70 | $wt = AE::timer 0.1, 0, $cv; |
73 | $wt = AE::timer 0.01, 0, $cv; |
71 | |
74 | |
72 | $s = 0; |
75 | $s = 0; |
73 | $cv->recv; |
76 | $cv->recv; |
74 | |
77 | |
75 | print $s == 0 ? "" : "not ", "ok 5 # $s\n"; |
78 | print $s == 0 ? "" : "not ", "ok 5 # $s\n"; |
76 | } |
79 | } |
77 | |
80 | |
78 | # signal |
81 | # signal |
79 | { |
82 | { |
80 | my $cv = AE::cv; |
83 | my $cv = AE::cv; |
81 | my $wt = AE::timer 0.1, 0, $cv; |
84 | my $wt = AE::timer 0.01, 0, $cv; |
82 | my $s = 0; |
85 | my $s = 0; |
83 | |
86 | |
84 | $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 }; |
87 | $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 }; |
85 | $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 }; |
88 | $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 }; |
86 | |
89 | |
… | |
… | |
89 | print $s == 0 ? "" : "not ", "ok 6 # $s\n"; |
92 | print $s == 0 ? "" : "not ", "ok 6 # $s\n"; |
90 | |
93 | |
91 | kill INT => $$; |
94 | kill INT => $$; |
92 | |
95 | |
93 | $cv = AE::cv; |
96 | $cv = AE::cv; |
94 | $wt = AE::timer 0.1, 0, $cv; |
97 | $wt = AE::timer 0.01, 0, $cv; |
95 | |
98 | |
96 | $s = 0; |
99 | $s = 0; |
97 | $cv->recv; |
100 | $cv->recv; |
98 | |
101 | |
99 | print $s == 3 ? "" : "not ", "ok 7 # $s\n"; |
102 | print $s == 3 ? "" : "not ", "ok 7 # $s\n"; |
100 | |
103 | |
101 | $cv = AE::cv; |
104 | $cv = AE::cv; |
102 | $wt = AE::timer 0.1, 0, $cv; |
105 | $wt = AE::timer 0.01, 0, $cv; |
103 | |
106 | |
104 | $s = 0; |
107 | $s = 0; |
105 | $cv->recv; |
108 | $cv->recv; |
106 | |
109 | |
107 | print $s == 0 ? "" : "not ", "ok 8 # $s\n"; |
110 | print $s == 0 ? "" : "not ", "ok 8 # $s\n"; |
… | |
… | |
110 | $AnyEvent::MAX_SIGNAL_LATENCY = 0.2; |
113 | $AnyEvent::MAX_SIGNAL_LATENCY = 0.2; |
111 | |
114 | |
112 | # child |
115 | # child |
113 | { |
116 | { |
114 | my $cv = AE::cv; |
117 | my $cv = AE::cv; |
115 | my $wt = AE::timer 0.1, 0, $cv; |
118 | my $wt = AE::timer 0.01, 0, $cv; |
116 | my $s = 0; |
119 | my $s = 0; |
117 | |
120 | |
118 | my $pid = fork; |
121 | my $pid = fork; |
119 | |
122 | |
120 | unless ($pid) { |
123 | unless ($pid) { |
… | |
… | |
132 | print $s == 0 ? "" : "not ", "ok 9 # $s\n"; |
135 | print $s == 0 ? "" : "not ", "ok 9 # $s\n"; |
133 | |
136 | |
134 | kill 9, $pid; |
137 | kill 9, $pid; |
135 | |
138 | |
136 | $cv = AE::cv; |
139 | $cv = AE::cv; |
137 | $wt = AE::timer 0.1, 0, $cv; |
140 | $wt = AE::timer 0.01, 0, $cv; |
138 | |
141 | |
139 | $s = 0; |
142 | $s = 0; |
140 | $cv->recv; |
143 | $cv->recv; |
141 | |
144 | |
142 | print $s == 3 ? "" : "not ", "ok 10 # $s\n"; |
145 | print $s == 3 ? "" : "not ", "ok 10 # $s\n"; |
143 | print $apid == $pid && $bpid == $pid ? "" : "not ", "ok 11 # $apid == $bpid == $pid\n"; |
146 | print $apid == $pid && $bpid == $pid ? "" : "not ", "ok 11 # $apid == $bpid == $pid\n"; |
144 | print $astatus == 9 && $bstatus == 9 ? "" : "not ", "ok 12 # $astatus == $bstatus == 9\n"; |
147 | print $astatus == 9 && $bstatus == 9 ? "" : "not ", "ok 12 # $astatus == $bstatus == 9\n"; |
145 | |
148 | |
146 | $cv = AE::cv; |
149 | $cv = AE::cv; |
147 | $wt = AE::timer 0.1, 0, $cv; |
150 | $wt = AE::timer 0.01, 0, $cv; |
148 | |
151 | |
149 | $s = 0; |
152 | $s = 0; |
150 | $cv->recv; |
153 | $cv->recv; |
151 | |
154 | |
152 | print $s == 0 ? "" : "not ", "ok 13 # $s\n"; |
155 | print $s == 0 ? "" : "not ", "ok 13 # $s\n"; |