Skip to content

Commit faaa772

Browse files
committed
#118 - Add test cases for yield with different scenarios
1 parent 10cd854 commit faaa772

File tree

5 files changed

+643
-0
lines changed

5 files changed

+643
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Empty yield statement
3+
--SKIPIF--
4+
<?php include(__DIR__ . '/../../skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
$code =<<<ZEP
8+
function test() {
9+
yield;
10+
}
11+
ZEP;
12+
13+
$ir = zephir_parse_file($code, '(eval code)');
14+
var_dump($ir[0]["statements"][0]);
15+
?>
16+
--EXPECT--
17+
array(4) {
18+
["type"]=>
19+
string(5) "yield"
20+
["file"]=>
21+
string(11) "(eval code)"
22+
["line"]=>
23+
int(3)
24+
["char"]=>
25+
int(1)
26+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
--TEST--
2+
Array yield statement
3+
--SKIPIF--
4+
<?php include(__DIR__ . '/../../skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
$code =<<<ZEP
8+
function test() {
9+
yield ['key': 'value', 'another', 'val'];
10+
}
11+
ZEP;
12+
13+
$ir = zephir_parse_file($code, '(eval code)');
14+
var_dump($ir[0]["statements"][0]);
15+
?>
16+
--EXPECT--
17+
array(5) {
18+
["type"]=>
19+
string(5) "yield"
20+
["expr"]=>
21+
array(5) {
22+
["type"]=>
23+
string(5) "array"
24+
["left"]=>
25+
array(3) {
26+
[0]=>
27+
array(5) {
28+
["key"]=>
29+
array(5) {
30+
["type"]=>
31+
string(4) "char"
32+
["value"]=>
33+
string(3) "key"
34+
["file"]=>
35+
string(11) "(eval code)"
36+
["line"]=>
37+
int(2)
38+
["char"]=>
39+
int(13)
40+
}
41+
["value"]=>
42+
array(5) {
43+
["type"]=>
44+
string(4) "char"
45+
["value"]=>
46+
string(5) "value"
47+
["file"]=>
48+
string(11) "(eval code)"
49+
["line"]=>
50+
int(2)
51+
["char"]=>
52+
int(21)
53+
}
54+
["file"]=>
55+
string(11) "(eval code)"
56+
["line"]=>
57+
int(2)
58+
["char"]=>
59+
int(21)
60+
}
61+
[1]=>
62+
array(4) {
63+
["value"]=>
64+
array(5) {
65+
["type"]=>
66+
string(4) "char"
67+
["value"]=>
68+
string(7) "another"
69+
["file"]=>
70+
string(11) "(eval code)"
71+
["line"]=>
72+
int(2)
73+
["char"]=>
74+
int(31)
75+
}
76+
["file"]=>
77+
string(11) "(eval code)"
78+
["line"]=>
79+
int(2)
80+
["char"]=>
81+
int(31)
82+
}
83+
[2]=>
84+
array(4) {
85+
["value"]=>
86+
array(5) {
87+
["type"]=>
88+
string(4) "char"
89+
["value"]=>
90+
string(3) "val"
91+
["file"]=>
92+
string(11) "(eval code)"
93+
["line"]=>
94+
int(2)
95+
["char"]=>
96+
int(37)
97+
}
98+
["file"]=>
99+
string(11) "(eval code)"
100+
["line"]=>
101+
int(2)
102+
["char"]=>
103+
int(37)
104+
}
105+
}
106+
["file"]=>
107+
string(11) "(eval code)"
108+
["line"]=>
109+
int(2)
110+
["char"]=>
111+
int(38)
112+
}
113+
["file"]=>
114+
string(11) "(eval code)"
115+
["line"]=>
116+
int(3)
117+
["char"]=>
118+
int(1)
119+
}

0 commit comments

Comments
 (0)