PageRenderTime 56ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/zend/good/ext/standard/tests/strings/vfprintf_variation19_64bit.php

http://github.com/facebook/hiphop-php
PHP | 61 lines | 44 code | 8 blank | 9 comment | 1 complexity | 99c606fddb3a1be4fd90bfc93f03259f MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh
  2. /* Prototype : int vfprintf ( resource $handle , string $format , array $args )
  3. * Description: Write a formatted string to a stream
  4. * Source code: ext/standard/formatted_print.c
  5. */
  6. <<__EntryPoint>> function main(): void {
  7. echo "*** Testing vfprintf() : with white spaces in format strings ***\n";
  8. // initializing the format array
  9. $formats = varray[
  10. "% d % d % d",
  11. "% f % f % f",
  12. "% F % F % F",
  13. "% b % b % b",
  14. "% c % c % c",
  15. "% e % e % e",
  16. "% u % u % u",
  17. "% o % o % o",
  18. "% x % x % x",
  19. "% X % X % X",
  20. "% E % E % E"
  21. ];
  22. // initializing the args array
  23. $args_array = varray[
  24. varray[111, 222, 333],
  25. varray[1.1, .2, -0.6],
  26. varray[1.12, -1.13, +0.23],
  27. varray[1, 2, 3],
  28. varray[65, 66, 67],
  29. varray[2e1, 2e-1, -2e1],
  30. varray[-11, +22, 33],
  31. varray[012, -02394, +02389],
  32. varray[0x11, -0x22, +0x33],
  33. varray[0x11, -0x22, +0x33],
  34. varray[2e1, 2e-1, -2e1]
  35. ];
  36. /* creating dumping file */
  37. $data_file = dirname(__FILE__) . '/vfprintf_variation19_64bit.txt';
  38. if (!($fp = fopen($data_file, 'wt')))
  39. return;
  40. // looping to test vfprintf() with different scientific formats from the above $format array
  41. // and with non-scientific values from the above $args_array array
  42. $counter = 1;
  43. foreach($formats as $format) {
  44. fprintf($fp, "\n-- Iteration %d --\n",$counter);
  45. vfprintf($fp,$format, $args_array[$counter-1]);
  46. $counter++;
  47. }
  48. fclose($fp);
  49. print_r(file_get_contents($data_file));
  50. echo "\n";
  51. unlink($data_file);
  52. echo "===DONE===\n";
  53. }