log_variation2.phpt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. --TEST--
  2. Test log() function : usage variations - different data types as $base argument
  3. --FILE--
  4. <?php
  5. /* Prototype : float log ( float $arg [, float $base ] )
  6. * Description: Natural logarithm.
  7. * Source code: ext/standard/math.c
  8. */
  9. echo "*** Testing log() : usage variations ***\n";
  10. //get an unset variable
  11. $unset_var = 10;
  12. unset ($unset_var);
  13. // heredoc string
  14. $heredoc = <<<EOT
  15. abc
  16. xyz
  17. EOT;
  18. // get a class
  19. class classA
  20. {
  21. }
  22. // get a resource variable
  23. $fp = fopen(__FILE__, "r");
  24. $inputs = array(
  25. // int data
  26. /*1*/ 0,
  27. 1,
  28. 12345,
  29. -2345,
  30. 2147483647,
  31. // float data
  32. /*6*/ 10.5,
  33. -10.5,
  34. 12.3456789000e10,
  35. 12.3456789000E-10,
  36. .5,
  37. // null data
  38. /*11*/ NULL,
  39. null,
  40. // boolean data
  41. /*13*/ true,
  42. false,
  43. TRUE,
  44. FALSE,
  45. // empty data
  46. /*17*/ "",
  47. '',
  48. array(),
  49. // string data
  50. /*20*/ "abcxyz",
  51. 'abcxyz',
  52. $heredoc,
  53. // object data
  54. /*23*/ new classA(),
  55. // undefined data
  56. /*24*/ @$undefined_var,
  57. // unset data
  58. /*25*/ @$unset_var,
  59. // resource variable
  60. /*26*/ $fp
  61. );
  62. // loop through each element of $inputs to check the behaviour of log()
  63. $iterator = 1;
  64. foreach($inputs as $input) {
  65. echo "\n-- Iteration $iterator --\n";
  66. var_dump(log(3.14, $input));
  67. $iterator++;
  68. };
  69. fclose($fp);
  70. ?>
  71. ===Done===
  72. --EXPECTF--
  73. *** Testing log() : usage variations ***
  74. -- Iteration 1 --
  75. Warning: log(): base must be greater than 0 in %s on line %d
  76. bool(false)
  77. -- Iteration 2 --
  78. float(NAN)
  79. -- Iteration 3 --
  80. float(0.12145441273706)
  81. -- Iteration 4 --
  82. Warning: log(): base must be greater than 0 in %s on line %d
  83. bool(false)
  84. -- Iteration 5 --
  85. float(0.053250469650086)
  86. -- Iteration 6 --
  87. float(0.48661854224853)
  88. -- Iteration 7 --
  89. Warning: log(): base must be greater than 0 in %s on line %d
  90. bool(false)
  91. -- Iteration 8 --
  92. float(0.044802684673473)
  93. -- Iteration 9 --
  94. float(-0.055781611216686)
  95. -- Iteration 10 --
  96. float(-1.6507645591169)
  97. -- Iteration 11 --
  98. Warning: log(): base must be greater than 0 in %s on line %d
  99. bool(false)
  100. -- Iteration 12 --
  101. Warning: log(): base must be greater than 0 in %s on line %d
  102. bool(false)
  103. -- Iteration 13 --
  104. float(NAN)
  105. -- Iteration 14 --
  106. Warning: log(): base must be greater than 0 in %s on line %d
  107. bool(false)
  108. -- Iteration 15 --
  109. float(NAN)
  110. -- Iteration 16 --
  111. Warning: log(): base must be greater than 0 in %s on line %d
  112. bool(false)
  113. -- Iteration 17 --
  114. Warning: log() expects parameter 2 to be double, string given in %s on line %d
  115. NULL
  116. -- Iteration 18 --
  117. Warning: log() expects parameter 2 to be double, string given in %s on line %d
  118. NULL
  119. -- Iteration 19 --
  120. Warning: log() expects parameter 2 to be double, array given in %s on line %d
  121. NULL
  122. -- Iteration 20 --
  123. Warning: log() expects parameter 2 to be double, string given in %s on line %d
  124. NULL
  125. -- Iteration 21 --
  126. Warning: log() expects parameter 2 to be double, string given in %s on line %d
  127. NULL
  128. -- Iteration 22 --
  129. Warning: log() expects parameter 2 to be double, string given in %s on line %d
  130. NULL
  131. -- Iteration 23 --
  132. Warning: log() expects parameter 2 to be double, object given in %s on line %d
  133. NULL
  134. -- Iteration 24 --
  135. Warning: log(): base must be greater than 0 in %s on line %d
  136. bool(false)
  137. -- Iteration 25 --
  138. Warning: log(): base must be greater than 0 in %s on line %d
  139. bool(false)
  140. -- Iteration 26 --
  141. Warning: log() expects parameter 2 to be double, resource given in %s on line %d
  142. NULL
  143. ===Done===