Skip to content

Commit

Permalink
#120 - Add extra test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Sep 15, 2021
1 parent c66ea70 commit 66d0ead
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/functions/parameter-types/int.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
--TEST--
Parameter type 'int'
--SKIPIF--
<?php include(__DIR__ . '/../skipif.inc'); ?>
--FILE--
<?php
$code =<<<ZEP
function test(int value) { }
ZEP;

$ir = zephir_parse_file($code, '(eval code)');
var_dump($ir);
?>
--EXPECT--
array(1) {
[0]=>
array(6) {
["type"]=>
string(8) "function"
["name"]=>
string(4) "test"
["parameters"]=>
array(1) {
[0]=>
array(9) {
["type"]=>
string(9) "parameter"
["name"]=>
string(5) "value"
["const"]=>
int(0)
["data-type"]=>
string(3) "int"
["mandatory"]=>
int(0)
["reference"]=>
int(0)
["file"]=>
string(11) "(eval code)"
["line"]=>
int(1)
["char"]=>
int(25)
}
}
["file"]=>
string(11) "(eval code)"
["line"]=>
int(1)
["char"]=>
int(9)
}
}
60 changes: 60 additions & 0 deletions tests/functions/return-types/int.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
--TEST--
Function definition with mandatory return type
--SKIPIF--
<?php include(__DIR__ . '/../skipif.inc'); ?>
--FILE--
<?php
$code =<<<ZEP
function test() -> int { }
ZEP;

$ir = zephir_parse_file($code, '(eval code)');
var_dump($ir);
?>
--EXPECT--
array(1) {
[0]=>
array(6) {
["type"]=>
string(8) "function"
["name"]=>
string(4) "test"
["return-type"]=>
array(6) {
["type"]=>
string(11) "return-type"
["list"]=>
array(1) {
[0]=>
array(6) {
["type"]=>
string(21) "return-type-parameter"
["data-type"]=>
string(3) "int"
["mandatory"]=>
int(0)
["file"]=>
string(11) "(eval code)"
["line"]=>
int(1)
["char"]=>
int(25)
}
}
["void"]=>
int(0)
["file"]=>
string(11) "(eval code)"
["line"]=>
int(1)
["char"]=>
int(25)
}
["file"]=>
string(11) "(eval code)"
["line"]=>
int(1)
["char"]=>
int(9)
}
}

0 comments on commit 66d0ead

Please sign in to comment.