Skip to content

Commit 2790351

Browse files
committed
Test code to check 'constant' type.
1 parent 04e962f commit 2790351

File tree

1 file changed

+62
-9
lines changed

1 file changed

+62
-9
lines changed

tests/base/types.phpt

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class Test
2222
2323
public t_char1 = 'a';
2424
25+
public t_const1 = FOOBAR;
26+
2527
public function someString()
2628
{
2729
return "hello";
@@ -36,9 +38,29 @@ ZEP;
3638

3739
$ir = zephir_parse_file($code, '(eval code)');
3840

41+
$properties = $ir[1]["definition"]["properties"];
42+
foreach ($properties as $property) {
43+
printf("%s %s %s %s\n",
44+
implode(",", $property["visibility"]),
45+
$property["name"],
46+
$property["default"]["type"],
47+
$property["default"]["value"]
48+
);
49+
}
50+
3951
var_dump($ir);
4052
?>
4153
--EXPECT--
54+
public t_int1 int 10
55+
public t_int2 int -100
56+
public t_int3 int 0xFFFFFF
57+
public t_int4 int -0x000000
58+
public t_double1 double 0.000001
59+
public t_double1 double -0.000001
60+
public t_double1 double 909.999999
61+
public t_double1 double -909.999999
62+
public t_char1 char a
63+
public t_const1 constant FOOBAR
4264
array(2) {
4365
[0]=>
4466
array(5) {
@@ -66,7 +88,7 @@ array(2) {
6688
["definition"]=>
6789
array(5) {
6890
["properties"]=>
69-
array(9) {
91+
array(10) {
7092
[0]=>
7193
array(7) {
7294
["visibility"]=>
@@ -346,6 +368,37 @@ array(2) {
346368
["char"]=>
347369
int(10)
348370
}
371+
[9]=>
372+
array(7) {
373+
["visibility"]=>
374+
array(1) {
375+
[0]=>
376+
string(6) "public"
377+
}
378+
["type"]=>
379+
string(8) "property"
380+
["name"]=>
381+
string(8) "t_const1"
382+
["default"]=>
383+
array(5) {
384+
["type"]=>
385+
string(8) "constant"
386+
["value"]=>
387+
string(6) "FOOBAR"
388+
["file"]=>
389+
string(11) "(eval code)"
390+
["line"]=>
391+
int(17)
392+
["char"]=>
393+
int(29)
394+
}
395+
["file"]=>
396+
string(11) "(eval code)"
397+
["line"]=>
398+
int(19)
399+
["char"]=>
400+
int(10)
401+
}
349402
}
350403
["methods"]=>
351404
array(2) {
@@ -375,24 +428,24 @@ array(2) {
375428
["file"]=>
376429
string(11) "(eval code)"
377430
["line"]=>
378-
int(19)
431+
int(21)
379432
["char"]=>
380433
int(21)
381434
}
382435
["file"]=>
383436
string(11) "(eval code)"
384437
["line"]=>
385-
int(20)
438+
int(22)
386439
["char"]=>
387440
int(5)
388441
}
389442
}
390443
["file"]=>
391444
string(11) "(eval code)"
392445
["line"]=>
393-
int(17)
446+
int(19)
394447
["last-line"]=>
395-
int(22)
448+
int(24)
396449
["char"]=>
397450
int(19)
398451
}
@@ -422,24 +475,24 @@ array(2) {
422475
["file"]=>
423476
string(11) "(eval code)"
424477
["line"]=>
425-
int(24)
478+
int(26)
426479
["char"]=>
427480
int(22)
428481
}
429482
["file"]=>
430483
string(11) "(eval code)"
431484
["line"]=>
432-
int(25)
485+
int(27)
433486
["char"]=>
434487
int(5)
435488
}
436489
}
437490
["file"]=>
438491
string(11) "(eval code)"
439492
["line"]=>
440-
int(22)
493+
int(24)
441494
["last-line"]=>
442-
int(26)
495+
int(28)
443496
["char"]=>
444497
int(19)
445498
}

0 commit comments

Comments
 (0)