010.phpt 1.4 KB

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