pow_variation2.phpt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. --TEST--
  2. Test pow() function : usage variations - different data types as $exp argument
  3. --INI--
  4. serialize_precision = 14
  5. --FILE--
  6. <?php
  7. echo "*** Testing pow() : usage variations ***\n";
  8. //get an unset variable
  9. $unset_var = 10;
  10. unset ($unset_var);
  11. // heredoc string
  12. $heredoc = <<<EOT
  13. abc
  14. xyz
  15. EOT;
  16. // get a class
  17. class classA
  18. {
  19. }
  20. // get a resource variable
  21. $fp = fopen(__FILE__, "r");
  22. $inputs = array(
  23. // int data
  24. /*1*/ 0,
  25. 1,
  26. 12345,
  27. -2345,
  28. 2147483647,
  29. // float data
  30. /*6*/ 2.5,
  31. -2.5,
  32. 12.3456789000e10,
  33. 12.3456789000E-10,
  34. .5,
  35. // null data
  36. /*11*/ NULL,
  37. null,
  38. // boolean data
  39. /*13*/ true,
  40. false,
  41. TRUE,
  42. FALSE,
  43. // empty data
  44. /*17*/ "",
  45. '',
  46. array(),
  47. // string data
  48. /*20*/ "abcxyz",
  49. 'abcxyz',
  50. $heredoc,
  51. // object data
  52. /*23*/ new classA(),
  53. // undefined data
  54. /*24*/ @$undefined_var,
  55. // unset data
  56. /*25*/ @$unset_var,
  57. // resource variable
  58. /*26*/ $fp
  59. );
  60. // loop through each element of $inputs to check the behaviour of pow()
  61. $iterator = 1;
  62. foreach($inputs as $input) {
  63. echo "\n-- Iteration $iterator --\n";
  64. try {
  65. var_dump(pow(20.3, $input));
  66. } catch (Error $e) {
  67. echo $e->getMessage(), "\n";
  68. }
  69. $iterator++;
  70. };
  71. fclose($fp);
  72. ?>
  73. --EXPECT--
  74. *** Testing pow() : usage variations ***
  75. -- Iteration 1 --
  76. float(1)
  77. -- Iteration 2 --
  78. float(20.3)
  79. -- Iteration 3 --
  80. float(INF)
  81. -- Iteration 4 --
  82. float(0)
  83. -- Iteration 5 --
  84. float(INF)
  85. -- Iteration 6 --
  86. float(1856.6929774279)
  87. -- Iteration 7 --
  88. float(0.00053859200856424)
  89. -- Iteration 8 --
  90. float(INF)
  91. -- Iteration 9 --
  92. float(1.0000000037168)
  93. -- Iteration 10 --
  94. float(4.5055521304275)
  95. -- Iteration 11 --
  96. float(1)
  97. -- Iteration 12 --
  98. float(1)
  99. -- Iteration 13 --
  100. float(20.3)
  101. -- Iteration 14 --
  102. float(1)
  103. -- Iteration 15 --
  104. float(20.3)
  105. -- Iteration 16 --
  106. float(1)
  107. -- Iteration 17 --
  108. Unsupported operand types: float ** string
  109. -- Iteration 18 --
  110. Unsupported operand types: float ** string
  111. -- Iteration 19 --
  112. Unsupported operand types: float ** array
  113. -- Iteration 20 --
  114. Unsupported operand types: float ** string
  115. -- Iteration 21 --
  116. Unsupported operand types: float ** string
  117. -- Iteration 22 --
  118. Unsupported operand types: float ** string
  119. -- Iteration 23 --
  120. Unsupported operand types: float ** classA
  121. -- Iteration 24 --
  122. float(1)
  123. -- Iteration 25 --
  124. float(1)
  125. -- Iteration 26 --
  126. Unsupported operand types: float ** resource