File tree Expand file tree Collapse file tree 2 files changed +93
-1
lines changed
tests/swoole_coroutine/interrupt Expand file tree Collapse file tree 2 files changed +93
-1
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ swoole_coroutine: interrupt: base
3
+ --SKIPIF--
4
+ <?php require __DIR__ . '/../../include/skipif.inc ' ; ?>
5
+ --FILE--
6
+ <?php
7
+ require __DIR__ . '/../../include/bootstrap.php ' ;
8
+
9
+ Co::cancel (go (function () {
10
+ var_dump (Co::sleep (1 ));
11
+ var_dump (Co::wasCancelled ());
12
+ }));
13
+
14
+ Co::shutdown (go (function () {
15
+ Co::yield ();
16
+ echo "never here \n" ;
17
+ }));
18
+
19
+ Co::throw (go (function () {
20
+ try {
21
+ Co::yield ();
22
+ } catch (Co \Exception $ e ) {
23
+ var_dump ($ e );
24
+ }
25
+ }));
26
+
27
+ ?>
28
+ --EXPECTF--
29
+ float(1)
30
+ bool(true)
31
+ object(Swoole\Coroutine\Exception)#1 (12) {
32
+ ["message":protected]=>
33
+ string(%d) "the coroutine was interrupted by an exception from cid#-1."
34
+ ["string":"Exception":private]=>
35
+ string(%d) ""
36
+ ["code":protected]=>
37
+ int(10016)
38
+ ["file":protected]=>
39
+ string(%d) "%s/tests/swoole_coroutine/interrupt/base.php"
40
+ ["line":protected]=>
41
+ int(16)
42
+ ["trace":"Exception":private]=>
43
+ array(1) {
44
+ [0]=>
45
+ array(6) {
46
+ ["file"]=>
47
+ string(%d) "%s/tests/swoole_coroutine/interrupt/base.php"
48
+ ["line"]=>
49
+ int(16)
50
+ ["function"]=>
51
+ string(%d) "yield"
52
+ ["class"]=>
53
+ string(%d) "Swoole\Coroutine"
54
+ ["type"]=>
55
+ string(%d) "::"
56
+ ["args"]=>
57
+ array(0) {
58
+ }
59
+ }
60
+ }
61
+ ["previous":"Exception":private]=>
62
+ NULL
63
+ ["cid":protected]=>
64
+ int(3)
65
+ ["originCid":protected]=>
66
+ int(-1)
67
+ ["originFile":protected]=>
68
+ string(%d) "%s/tests/swoole_coroutine/interrupt/base.php"
69
+ ["originLine":protected]=>
70
+ int(20)
71
+ ["originTrace":protected]=>
72
+ array(1) {
73
+ [0]=>
74
+ array(6) {
75
+ ["file"]=>
76
+ string(%d) "%s/tests/swoole_coroutine/interrupt/base.php"
77
+ ["line"]=>
78
+ int(20)
79
+ ["function"]=>
80
+ string(%d) "throw"
81
+ ["class"]=>
82
+ string(%d) "Swoole\Coroutine"
83
+ ["type"]=>
84
+ string(%d) "::"
85
+ ["args"]=>
86
+ array(1) {
87
+ [0]=>
88
+ int(3)
89
+ }
90
+ }
91
+ }
92
+ }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ $yield = go(function () {
16
16
});
17
17
18
18
$ sleep = go (function () {
19
- if (($ ret = Co::sleep (1 )) === 0 ) {
19
+ if (($ ret = Co::sleep (1 )) == 0 ) {
20
20
echo "normal termination \n" ;
21
21
} else {
22
22
echo "time left {$ ret }s \n" ;
You can’t perform that action at this time.
0 commit comments