1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/ext/standard/tests/math/hypot_basic.phpt
Nikita Popov b10416a652 Deprecate passing null to non-nullable arg of internal function
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Closes GH-6475.
2021-02-11 21:46:13 +01:00

286 lines
5.1 KiB
PHP

--TEST--
Test hypot() - basic function test hypot()
--INI--
serialize_precision=15
--FILE--
<?php
echo "*** Testing hypot() : basic functionality ***\n";
$valuesy = array(23,
-23,
2.345e1,
-2.345e1,
0x17,
027,
"23",
"23.45",
"2.345e1",
true,
false);
$valuesx = array(33,
-33,
3.345e1,
-3.345e1,
0x27,
037,
"33",
"43.45",
"1.345e1",
true,
false);
for ($i = 0; $i < count($valuesy); $i++) {
for ($j = 0; $j < count($valuesx); $j++) {
echo "\nY:$valuesy[$i] X:$valuesx[$j] ";
$res = hypot($valuesy[$i], $valuesx[$j]);
var_dump($res);
}
}
?>
--EXPECT--
*** Testing hypot() : basic functionality ***
Y:23 X:33 float(40.2243707222375)
Y:23 X:-33 float(40.2243707222375)
Y:23 X:33.45 float(40.5943653725489)
Y:23 X:-33.45 float(40.5943653725489)
Y:23 X:39 float(45.2769256906871)
Y:23 X:31 float(38.6005181312376)
Y:23 X:33 float(40.2243707222375)
Y:23 X:43.45 float(49.1620026036369)
Y:23 X:1.345e1 float(26.6439955712352)
Y:23 X:1 float(23.0217288664427)
Y:23 X: float(23)
Y:-23 X:33 float(40.2243707222375)
Y:-23 X:-33 float(40.2243707222375)
Y:-23 X:33.45 float(40.5943653725489)
Y:-23 X:-33.45 float(40.5943653725489)
Y:-23 X:39 float(45.2769256906871)
Y:-23 X:31 float(38.6005181312376)
Y:-23 X:33 float(40.2243707222375)
Y:-23 X:43.45 float(49.1620026036369)
Y:-23 X:1.345e1 float(26.6439955712352)
Y:-23 X:1 float(23.0217288664427)
Y:-23 X: float(23)
Y:23.45 X:33 float(40.483360779461)
Y:23.45 X:-33 float(40.483360779461)
Y:23.45 X:33.45 float(40.8510097794412)
Y:23.45 X:-33.45 float(40.8510097794412)
Y:23.45 X:39 float(45.5071697647744)
Y:23.45 X:31 float(38.8703293014093)
Y:23.45 X:33 float(40.483360779461)
Y:23.45 X:43.45 float(49.3741329037787)
Y:23.45 X:1.345e1 float(27.033405260899)
Y:23.45 X:1 float(23.4713122769052)
Y:23.45 X: float(23.45)
Y:-23.45 X:33 float(40.483360779461)
Y:-23.45 X:-33 float(40.483360779461)
Y:-23.45 X:33.45 float(40.8510097794412)
Y:-23.45 X:-33.45 float(40.8510097794412)
Y:-23.45 X:39 float(45.5071697647744)
Y:-23.45 X:31 float(38.8703293014093)
Y:-23.45 X:33 float(40.483360779461)
Y:-23.45 X:43.45 float(49.3741329037787)
Y:-23.45 X:1.345e1 float(27.033405260899)
Y:-23.45 X:1 float(23.4713122769052)
Y:-23.45 X: float(23.45)
Y:23 X:33 float(40.2243707222375)
Y:23 X:-33 float(40.2243707222375)
Y:23 X:33.45 float(40.5943653725489)
Y:23 X:-33.45 float(40.5943653725489)
Y:23 X:39 float(45.2769256906871)
Y:23 X:31 float(38.6005181312376)
Y:23 X:33 float(40.2243707222375)
Y:23 X:43.45 float(49.1620026036369)
Y:23 X:1.345e1 float(26.6439955712352)
Y:23 X:1 float(23.0217288664427)
Y:23 X: float(23)
Y:23 X:33 float(40.2243707222375)
Y:23 X:-33 float(40.2243707222375)
Y:23 X:33.45 float(40.5943653725489)
Y:23 X:-33.45 float(40.5943653725489)
Y:23 X:39 float(45.2769256906871)
Y:23 X:31 float(38.6005181312376)
Y:23 X:33 float(40.2243707222375)
Y:23 X:43.45 float(49.1620026036369)
Y:23 X:1.345e1 float(26.6439955712352)
Y:23 X:1 float(23.0217288664427)
Y:23 X: float(23)
Y:23 X:33 float(40.2243707222375)
Y:23 X:-33 float(40.2243707222375)
Y:23 X:33.45 float(40.5943653725489)
Y:23 X:-33.45 float(40.5943653725489)
Y:23 X:39 float(45.2769256906871)
Y:23 X:31 float(38.6005181312376)
Y:23 X:33 float(40.2243707222375)
Y:23 X:43.45 float(49.1620026036369)
Y:23 X:1.345e1 float(26.6439955712352)
Y:23 X:1 float(23.0217288664427)
Y:23 X: float(23)
Y:23.45 X:33 float(40.483360779461)
Y:23.45 X:-33 float(40.483360779461)
Y:23.45 X:33.45 float(40.8510097794412)
Y:23.45 X:-33.45 float(40.8510097794412)
Y:23.45 X:39 float(45.5071697647744)
Y:23.45 X:31 float(38.8703293014093)
Y:23.45 X:33 float(40.483360779461)
Y:23.45 X:43.45 float(49.3741329037787)
Y:23.45 X:1.345e1 float(27.033405260899)
Y:23.45 X:1 float(23.4713122769052)
Y:23.45 X: float(23.45)
Y:2.345e1 X:33 float(40.483360779461)
Y:2.345e1 X:-33 float(40.483360779461)
Y:2.345e1 X:33.45 float(40.8510097794412)
Y:2.345e1 X:-33.45 float(40.8510097794412)
Y:2.345e1 X:39 float(45.5071697647744)
Y:2.345e1 X:31 float(38.8703293014093)
Y:2.345e1 X:33 float(40.483360779461)
Y:2.345e1 X:43.45 float(49.3741329037787)
Y:2.345e1 X:1.345e1 float(27.033405260899)
Y:2.345e1 X:1 float(23.4713122769052)
Y:2.345e1 X: float(23.45)
Y:1 X:33 float(33.0151480384384)
Y:1 X:-33 float(33.0151480384384)
Y:1 X:33.45 float(33.4649443447916)
Y:1 X:-33.45 float(33.4649443447916)
Y:1 X:39 float(39.0128184062623)
Y:1 X:31 float(31.0161248385416)
Y:1 X:33 float(33.0151480384384)
Y:1 X:43.45 float(43.4615059564208)
Y:1 X:1.345e1 float(13.4871234887206)
Y:1 X:1 float(1.4142135623731)
Y:1 X: float(1)
Y: X:33 float(33)
Y: X:-33 float(33)
Y: X:33.45 float(33.45)
Y: X:-33.45 float(33.45)
Y: X:39 float(39)
Y: X:31 float(31)
Y: X:33 float(33)
Y: X:43.45 float(43.45)
Y: X:1.345e1 float(13.45)
Y: X:1 float(1)
Y: X: float(0)