PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

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