ceil_variation1.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. --TEST--
  2. Test ceil() function : usage variations - different data types as $value arg
  3. --INI--
  4. precision=14
  5. --FILE--
  6. <?php
  7. echo "*** Testing ceil() : usage variations ***\n";
  8. //get an unset variable
  9. $unset_var = 10;
  10. unset ($unset_var);
  11. // get a class
  12. class classA
  13. {
  14. }
  15. // heredoc string
  16. $heredoc = <<<EOT
  17. abc
  18. xyz
  19. EOT;
  20. // get a resource variable
  21. $fp = fopen(__FILE__, "r");
  22. // unexpected values to be passed to $value argument
  23. $inputs = array(
  24. // null data
  25. /* 1*/ NULL,
  26. null,
  27. // boolean data
  28. /* 3*/ true,
  29. false,
  30. TRUE,
  31. FALSE,
  32. // empty data
  33. /* 7*/ "",
  34. '',
  35. array(),
  36. // string data
  37. /*10*/ "abcxyz",
  38. 'abcxyz}',
  39. $heredoc,
  40. // object data
  41. /*13*/ new classA(),
  42. // undefined data
  43. /*14*/ @$undefined_var,
  44. // unset data
  45. /*15*/ @$unset_var,
  46. // resource variable
  47. /*16*/ $fp
  48. );
  49. // loop through each element of $inputs to check the behaviour of ceil()
  50. $iterator = 1;
  51. foreach($inputs as $input) {
  52. echo "\n-- Iteration $iterator --\n";
  53. try {
  54. var_dump(ceil($input));
  55. } catch (TypeError $e) {
  56. echo $e->getMessage(), "\n";
  57. }
  58. $iterator++;
  59. };
  60. fclose($fp);
  61. ?>
  62. --EXPECTF--
  63. *** Testing ceil() : usage variations ***
  64. -- Iteration 1 --
  65. Deprecated: ceil(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
  66. float(0)
  67. -- Iteration 2 --
  68. Deprecated: ceil(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
  69. float(0)
  70. -- Iteration 3 --
  71. float(1)
  72. -- Iteration 4 --
  73. float(0)
  74. -- Iteration 5 --
  75. float(1)
  76. -- Iteration 6 --
  77. float(0)
  78. -- Iteration 7 --
  79. ceil(): Argument #1 ($num) must be of type int|float, string given
  80. -- Iteration 8 --
  81. ceil(): Argument #1 ($num) must be of type int|float, string given
  82. -- Iteration 9 --
  83. ceil(): Argument #1 ($num) must be of type int|float, array given
  84. -- Iteration 10 --
  85. ceil(): Argument #1 ($num) must be of type int|float, string given
  86. -- Iteration 11 --
  87. ceil(): Argument #1 ($num) must be of type int|float, string given
  88. -- Iteration 12 --
  89. ceil(): Argument #1 ($num) must be of type int|float, string given
  90. -- Iteration 13 --
  91. ceil(): Argument #1 ($num) must be of type int|float, classA given
  92. -- Iteration 14 --
  93. Deprecated: ceil(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
  94. float(0)
  95. -- Iteration 15 --
  96. Deprecated: ceil(): Passing null to parameter #1 ($num) of type int|float is deprecated in %s on line %d
  97. float(0)
  98. -- Iteration 16 --
  99. ceil(): Argument #1 ($num) must be of type int|float, resource given