PageRenderTime 45ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/facebook/hiphop-php
PHP | 54 lines | 32 code | 8 blank | 14 comment | 1 complexity | 945dd831b462f0203e79a23032be291d 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. /*
  7. * Test vfprintf() when different unsigned formats and unsigned values
  8. * are passed to the '$format' and '$args' arguments of the function
  9. */
  10. <<__EntryPoint>> function main(): void {
  11. echo "*** Testing vfprintf() : unsigned formats and unsigned values ***\n";
  12. // defining array of unsigned formats
  13. $formats = varray[
  14. '%u %+u %-u',
  15. '%lu %Lu %4u %-4u',
  16. '%10.4u %-10.4u %.4u',
  17. '%\'#2u %\'2u %\'$2u %\'_2u',
  18. '%3$u %4$u %1$u %2$u'
  19. ];
  20. // Arrays of unsigned values for the format defined in $format.
  21. // Each sub array contains unsigned values which correspond to each format string in $format
  22. $args_array = varray[
  23. varray[1234567, 01234567, 0 ],
  24. varray[12345678900, 12345678900, 1234, 12345],
  25. varray["1234000", 10.1234567e10, 1.2e2],
  26. varray[1, 0, 00, "10_"],
  27. varray[3, 4, 1, 2]
  28. ];
  29. /* creating dumping file */
  30. $data_file = dirname(__FILE__) . '/vfprintf_variation15_64bit.txt';
  31. if (!($fp = fopen($data_file, 'wt')))
  32. return;
  33. // looping to test vfprintf() with different unsigned formats from the above $format array
  34. // and with signed and other types of values from the above $args_array array
  35. $counter = 1;
  36. foreach($formats as $format) {
  37. fprintf($fp, "\n-- Iteration %d --\n",$counter);
  38. vfprintf($fp, $format, $args_array[$counter-1]);
  39. $counter++;
  40. }
  41. fclose($fp);
  42. print_r(file_get_contents($data_file));
  43. echo "\n";
  44. unlink($data_file);
  45. echo "===DONE===\n";
  46. }