xref: /PHP-8.0/tests/func/010.phpt (revision f8d79582)
1--TEST--
2function with many parameters
3--SKIPIF--
4<?php
5if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
6?>
7--FILE--
8<?php
9
10// the stack size + some random constant
11$boundary = 16*1024-16;
12$limit    = $boundary+42;
13
14
15function test($a,$b)
16{
17    var_dump($a === $b);
18    test2($a,$b);
19}
20
21function test2($a, $b)
22{
23    if ($a !== $b) {
24        var_dump("something went wrong: $a !== $b");
25    }
26}
27
28
29// generate the function
30$str = "<?php\nfunction x(";
31
32for($i=0; $i < $limit; ++$i) {
33    $str .= '$v'.dechex($i).($i===($limit-1) ? '' : ',');
34}
35
36$str .= ') {
37    test($v42, \'42\');
38    test(\'4000\', $v4000);
39    test2($v300, \'300\');
40    test($v0, \'0\'); // first
41    test($v'.dechex($limit-1).", '".dechex($limit-1).'\'); // last
42    test($v'.dechex($boundary).", '".dechex($boundary).'\'); //boundary
43    test($v'.dechex($boundary+1).", '".dechex($boundary+1).'\'); //boundary+1
44    test($v'.dechex($boundary-1).", '".dechex($boundary-1).'\'); //boundary-1
45}';
46
47// generate the function call
48$str .= "\n\nx(";
49
50for($i=0; $i< $limit; ++$i) {
51    $str .= "'".dechex($i)."'".($i===($limit-1) ? '' : ',');
52}
53
54$str .= ");\n";
55
56$filename = __DIR__.'/010-file.php';
57file_put_contents(__DIR__.'/010-file.php', $str);
58unset($str);
59
60include($filename);
61
62echo "Done\n";
63
64?>
65--CLEAN--
66<?php
67@unlink(__DIR__.'/010-file.php');
68?>
69--EXPECT--
70bool(true)
71bool(true)
72bool(true)
73bool(true)
74bool(true)
75bool(true)
76bool(true)
77Done
78