pow_variation1.phpt 2.5 KB

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