PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/test/zend/bad/ext/date/tests/gettimeofday_variation1.php

http://github.com/facebook/hiphop-php
PHP | 98 lines | 56 code | 21 blank | 21 comment | 0 complexity | 8922d5b0c01572e5ada62c9df63b4d0e 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. <?php
  2. /* Prototype : array gettimeofday([bool get_as_float])
  3. * Description: Returns the current time as array
  4. * Source code: ext/standard/microtime.c
  5. * Alias to functions:
  6. */
  7. echo "*** Testing gettimeofday() : usage variation ***\n";
  8. date_default_timezone_set("Asia/Calcutta");
  9. //get an unset variable
  10. $unset_var = 10;
  11. unset ($unset_var);
  12. // define some classes
  13. class classWithToString
  14. {
  15. public function __toString() {
  16. return "Class A object";
  17. }
  18. }
  19. class classWithoutToString
  20. {
  21. }
  22. // heredoc string
  23. $heredoc = <<<EOT
  24. hello world
  25. EOT;
  26. // add arrays
  27. $index_array = array (1, 2, 3);
  28. $assoc_array = array ('one' => 1, 'two' => 2);
  29. //array of values to iterate over
  30. $inputs = array(
  31. // int data
  32. 'int 0' => 0,
  33. 'int 1' => 1,
  34. 'int 12345' => 12345,
  35. 'int -12345' => -12345,
  36. // float data
  37. 'float 10.5' => 10.5,
  38. 'float -10.5' => -10.5,
  39. 'float 12.3456789000e10' => 12.3456789000e10,
  40. 'float -12.3456789000e10' => -12.3456789000e10,
  41. 'float .5' => .5,
  42. // array data
  43. 'empty array' => array(),
  44. 'int indexed array' => $index_array,
  45. 'associative array' => $assoc_array,
  46. 'nested arrays' => array('foo', $index_array, $assoc_array),
  47. // null data
  48. 'uppercase NULL' => NULL,
  49. 'lowercase null' => null,
  50. // boolean data
  51. 'lowercase true' => true,
  52. 'lowercase false' =>false,
  53. 'uppercase TRUE' =>TRUE,
  54. 'uppercase FALSE' =>FALSE,
  55. // empty data
  56. 'empty string DQ' => "",
  57. 'empty string SQ' => '',
  58. // string data
  59. 'string DQ' => "string",
  60. 'string SQ' => 'string',
  61. 'mixed case string' => "sTrInG",
  62. 'heredoc' => $heredoc,
  63. // object data
  64. 'instance of classWithToString' => new classWithToString(),
  65. 'instance of classWithoutToString' => new classWithoutToString(),
  66. // undefined data
  67. 'undefined var' => @$undefined_var,
  68. // unset data
  69. 'unset var' => @$unset_var,
  70. );
  71. // loop through each element of the array for get_as_float
  72. foreach($inputs as $key =>$value) {
  73. echo "\n--$key--\n";
  74. var_dump( gettimeofday($value) );
  75. };
  76. ?>
  77. ===DONE===