1--TEST--
2Check max() optimisation for int and float types
3--SKIPIF--
4<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
5--FILE--
6<?php
7
8echo "Start as int optimisation:\n";
9var_dump(max(10, 5, 3, 2));
10var_dump(max(2, 3, 5, 10));
11var_dump(max(10, 5, 3.5, 2));
12var_dump(max(2, 3.5, 5, 10));
13var_dump(max(10, 5, "3", 2));
14var_dump(max(2, "3", 5, 10));
15var_dump(max(2, 3, "15", 10));
16echo "Check that int not representable as float works:\n";
17var_dump(max(PHP_INT_MIN+1, PHP_INT_MIN, PHP_INT_MIN*2));
18var_dump(max(PHP_INT_MAX-1, PHP_INT_MAX, PHP_INT_MAX*2));
19// Has INF
20var_dump(max(PHP_INT_MAX-1, PHP_INT_MAX, PHP_INT_MAX**20));
21
22echo "Start as float optimisation:\n";
23var_dump(max(10.5, 5.5, 3.5, 2.5));
24var_dump(max(2.5, 3.5, 5.5, 10.5));
25var_dump(max(10.5, 5.5, 3, 2.5));
26var_dump(max(2.5, 3, 5.5, 10.5));
27var_dump(max(10.5, 5.5, "3.5", 2.5));
28var_dump(max(2.5, "3.5", 5.5, 10.5));
29var_dump(max(2.5, 3.5, "15.5", 10.5));
30echo "Check that int not representable as float works:\n";
31var_dump(max(PHP_INT_MIN*2, PHP_INT_MIN, PHP_INT_MIN+1));
32var_dump(max(PHP_INT_MAX*2, PHP_INT_MAX, PHP_INT_MAX-1));
33// Has INF
34var_dump(max(PHP_INT_MAX**20, PHP_INT_MAX, PHP_INT_MAX-1));
35
36?>
37--EXPECT--
38Start as int optimisation:
39int(10)
40int(10)
41int(10)
42int(10)
43int(10)
44int(10)
45string(2) "15"
46Check that int not representable as float works:
47int(-9223372036854775807)
48float(1.8446744073709552E+19)
49float(INF)
50Start as float optimisation:
51float(10.5)
52float(10.5)
53float(10.5)
54float(10.5)
55float(10.5)
56float(10.5)
57string(4) "15.5"
58Check that int not representable as float works:
59int(-9223372036854775807)
60float(1.8446744073709552E+19)
61float(INF)
62