Skip to content

Commit 86989ba

Browse files
committed
Add test for comment before namespace
1 parent 49e9758 commit 86989ba

File tree

3 files changed

+157
-3
lines changed

3 files changed

+157
-3
lines changed

tests/base/comments_before.phpt

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
--TEST--
2+
Comments before namespace
3+
--SKIPIF--
4+
<?php include(__DIR__ . '/../skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
$code1 =<<<ZEP
9+
/* some comment */
10+
11+
namespace Example;
12+
13+
class Test
14+
{
15+
}
16+
ZEP;
17+
18+
$code2 =<<<ZEP
19+
// some comment
20+
21+
namespace Example;
22+
23+
class Test
24+
{
25+
}
26+
ZEP;
27+
28+
$code3 =<<<ZEP
29+
/**
30+
* some comment
31+
*/
32+
33+
namespace Example;
34+
35+
class Test
36+
{
37+
}
38+
ZEP;
39+
40+
var_dump(zephir_parse_file($code1, '(eval code)'));
41+
var_dump(zephir_parse_file($code2, '(eval code)'));
42+
var_dump(zephir_parse_file($code3, '(eval code)'));
43+
--EXPECT--
44+
array(2) {
45+
[0]=>
46+
array(5) {
47+
["type"]=>
48+
string(9) "namespace"
49+
["name"]=>
50+
string(7) "Example"
51+
["file"]=>
52+
string(11) "(eval code)"
53+
["line"]=>
54+
int(5)
55+
["char"]=>
56+
int(5)
57+
}
58+
[1]=>
59+
array(8) {
60+
["type"]=>
61+
string(5) "class"
62+
["name"]=>
63+
string(4) "Test"
64+
["abstract"]=>
65+
int(0)
66+
["final"]=>
67+
int(0)
68+
["file"]=>
69+
string(11) "(eval code)"
70+
["line"]=>
71+
int(5)
72+
["char"]=>
73+
int(5)
74+
}
75+
}
76+
array(2) {
77+
[0]=>
78+
array(5) {
79+
["type"]=>
80+
string(9) "namespace"
81+
["name"]=>
82+
string(7) "Example"
83+
["file"]=>
84+
string(11) "(eval code)"
85+
["line"]=>
86+
int(5)
87+
["char"]=>
88+
int(5)
89+
}
90+
[1]=>
91+
array(8) {
92+
["type"]=>
93+
string(5) "class"
94+
["name"]=>
95+
string(4) "Test"
96+
["abstract"]=>
97+
int(0)
98+
["final"]=>
99+
int(0)
100+
["file"]=>
101+
string(11) "(eval code)"
102+
["line"]=>
103+
int(5)
104+
["char"]=>
105+
int(5)
106+
}
107+
}
108+
array(3) {
109+
[0]=>
110+
array(5) {
111+
["type"]=>
112+
string(7) "comment"
113+
["value"]=>
114+
string(21) "**
115+
* some comment
116+
*"
117+
["file"]=>
118+
string(11) "(eval code)"
119+
["line"]=>
120+
int(5)
121+
["char"]=>
122+
int(9)
123+
}
124+
[1]=>
125+
array(5) {
126+
["type"]=>
127+
string(9) "namespace"
128+
["name"]=>
129+
string(7) "Example"
130+
["file"]=>
131+
string(11) "(eval code)"
132+
["line"]=>
133+
int(7)
134+
["char"]=>
135+
int(5)
136+
}
137+
[2]=>
138+
array(8) {
139+
["type"]=>
140+
string(5) "class"
141+
["name"]=>
142+
string(4) "Test"
143+
["abstract"]=>
144+
int(0)
145+
["final"]=>
146+
int(0)
147+
["file"]=>
148+
string(11) "(eval code)"
149+
["line"]=>
150+
int(7)
151+
["char"]=>
152+
int(5)
153+
}
154+
}

tests/base/empty01.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--TEST--
2-
test me
2+
Should return an empty array in case of empty file
33
--SKIPIF--
44
<?php include(__DIR__ . '/../skipif.inc'); ?>
55
--FILE--
6-
<?php var_dump(zephir_parse_file(' ', '(eval code)')); ?>
6+
<?php var_dump(zephir_parse_file('', '(eval code)')); ?>
77
--EXPECT--
88
array(0) {
99
}

tests/base/empty02.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
test me
2+
Should return an empty array in case if all characters are whitespace
33
--SKIPIF--
44
<?php include(__DIR__ . '/../skipif.inc'); ?>
55
--FILE--

0 commit comments

Comments
 (0)