mirror of
https://github.com/php/php-src.git
synced 2026-04-29 19:23:22 +02:00
1e82ad8038
Squashed commit of the following: commite05d3b6732Author: Andrea Faulds <ajf@ajf.me> Date: Wed Mar 30 01:43:35 2016 +0100 UPGRADING and NEWS commit6caf1d4585Author: Andrea Faulds <ajf@ajf.me> Date: Sun Mar 20 21:18:33 2016 +0000 Fixes commit6dadb1b0efAuthor: Andrea Faulds <ajf@ajf.me> Date: Sun Feb 14 02:15:01 2016 +0000 Add test for numeric string errors in assignment commitbd5f04e8ddAuthor: Andrea Faulds <ajf@ajf.me> Date: Sat Feb 13 23:53:05 2016 +0000 Add test for numeric string errors commitc72e92f16dAuthor: Andrea Faulds <ajf@ajf.me> Date: Tue Jan 26 23:28:33 2016 +0000 Add test for scientific notation in integer operations commitd94c08852dAuthor: Andrea Faulds <ajf@ajf.me> Date: Sun Feb 14 01:25:57 2016 +0000 Disable optimiser evaluation for numeric string errors commit30ee954ed1Author: Andrea Faulds <ajf@ajf.me> Date: Sun Feb 14 01:46:25 2016 +0000 fixup commita6403b79e0Author: Andrea Faulds <ajf@ajf.me> Date: Sat Feb 13 22:00:27 2016 +0000 Do not convert error-causing numeric strings ahead-of-time commitf9dc354014Author: Andrea Faulds <ajf@ajf.me> Date: Sat Feb 13 19:15:38 2016 +0000 Disable compile-time evaluation for numeric string errors commite05b0cc849Author: Andrea Faulds <ajf@ajf.me> Date: Fri Feb 5 11:42:26 2016 +0000 Make _zval_get_long_func_noisy function for inlining commit84d66321a5Author: Andrea Faulds <ajf@ajf.me> Date: Tue Jan 26 23:10:00 2016 +0000 Update tests commit5ac4a0cc4bAuthor: Andrea Faulds <ajf@ajf.me> Date: Tue Jan 26 22:08:19 2016 +0000 Use is_numeric_string_ex for zval_get_long etc. commitc21f088485Author: Andrea Faulds <ajf@ajf.me> Date: Thu Jan 7 21:13:04 2016 +0000 Update tests commit63e214cf81Author: Andrea Faulds <ajf@ajf.me> Date: Wed Jan 6 00:28:01 2016 +0000 Warn on non-/bad numeric strings in arithmetic
183 lines
2.6 KiB
PHP
183 lines
2.6 KiB
PHP
--TEST--
|
|
Test pow() function : usage variations - different data types as $exp argument
|
|
--INI--
|
|
precision = 14
|
|
--FILE--
|
|
<?php
|
|
/* Prototype : number pow ( number $base , number $exp )
|
|
* Description: Exponential expression.
|
|
* Source code: ext/standard/math.c
|
|
*/
|
|
|
|
echo "*** Testing pow() : usage variations ***\n";
|
|
|
|
//get an unset variable
|
|
$unset_var = 10;
|
|
unset ($unset_var);
|
|
|
|
// heredoc string
|
|
$heredoc = <<<EOT
|
|
abc
|
|
xyz
|
|
EOT;
|
|
|
|
// get a class
|
|
class classA
|
|
{
|
|
}
|
|
|
|
// get a resource variable
|
|
$fp = fopen(__FILE__, "r");
|
|
|
|
$inputs = array(
|
|
// int data
|
|
/*1*/ 0,
|
|
1,
|
|
12345,
|
|
-2345,
|
|
2147483647,
|
|
|
|
// float data
|
|
/*6*/ 2.5,
|
|
-2.5,
|
|
12.3456789000e10,
|
|
12.3456789000E-10,
|
|
.5,
|
|
|
|
// null data
|
|
/*11*/ NULL,
|
|
null,
|
|
|
|
// boolean data
|
|
/*13*/ true,
|
|
false,
|
|
TRUE,
|
|
FALSE,
|
|
|
|
// empty data
|
|
/*17*/ "",
|
|
'',
|
|
array(),
|
|
|
|
// string data
|
|
/*20*/ "abcxyz",
|
|
'abcxyz',
|
|
$heredoc,
|
|
|
|
// object data
|
|
/*23*/ new classA(),
|
|
|
|
// undefined data
|
|
/*24*/ @$undefined_var,
|
|
|
|
// unset data
|
|
/*25*/ @$unset_var,
|
|
|
|
// resource variable
|
|
/*26*/ $fp
|
|
);
|
|
|
|
// loop through each element of $inputs to check the behaviour of pow()
|
|
$iterator = 1;
|
|
foreach($inputs as $input) {
|
|
echo "\n-- Iteration $iterator --\n";
|
|
var_dump(pow(20.3, $input));
|
|
$iterator++;
|
|
};
|
|
fclose($fp);
|
|
?>
|
|
===Done===
|
|
--EXPECTF--
|
|
*** Testing pow() : usage variations ***
|
|
|
|
-- Iteration 1 --
|
|
float(1)
|
|
|
|
-- Iteration 2 --
|
|
float(20.3)
|
|
|
|
-- Iteration 3 --
|
|
float(INF)
|
|
|
|
-- Iteration 4 --
|
|
float(0)
|
|
|
|
-- Iteration 5 --
|
|
float(INF)
|
|
|
|
-- Iteration 6 --
|
|
float(1856.6929774279)
|
|
|
|
-- Iteration 7 --
|
|
float(0.00053859200856424)
|
|
|
|
-- Iteration 8 --
|
|
float(INF)
|
|
|
|
-- Iteration 9 --
|
|
float(1.0000000037168)
|
|
|
|
-- Iteration 10 --
|
|
float(4.5055521304275)
|
|
|
|
-- Iteration 11 --
|
|
float(1)
|
|
|
|
-- Iteration 12 --
|
|
float(1)
|
|
|
|
-- Iteration 13 --
|
|
float(20.3)
|
|
|
|
-- Iteration 14 --
|
|
float(1)
|
|
|
|
-- Iteration 15 --
|
|
float(20.3)
|
|
|
|
-- Iteration 16 --
|
|
float(1)
|
|
|
|
-- Iteration 17 --
|
|
|
|
Warning: A non-numeric value encountered in %s on line %d
|
|
float(1)
|
|
|
|
-- Iteration 18 --
|
|
|
|
Warning: A non-numeric value encountered in %s on line %d
|
|
float(1)
|
|
|
|
-- Iteration 19 --
|
|
int(1)
|
|
|
|
-- Iteration 20 --
|
|
|
|
Warning: A non-numeric value encountered in %s on line %d
|
|
float(1)
|
|
|
|
-- Iteration 21 --
|
|
|
|
Warning: A non-numeric value encountered in %s on line %d
|
|
float(1)
|
|
|
|
-- Iteration 22 --
|
|
|
|
Warning: A non-numeric value encountered in %s on line %d
|
|
float(1)
|
|
|
|
-- Iteration 23 --
|
|
|
|
Notice: Object of class classA could not be converted to int in %s on line %d
|
|
float(20.3)
|
|
|
|
-- Iteration 24 --
|
|
float(1)
|
|
|
|
-- Iteration 25 --
|
|
float(1)
|
|
|
|
-- Iteration 26 --
|
|
%s
|
|
===Done===
|