1--TEST--
2Check min() 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(min(10, 5, 3, 2));
10var_dump(min(2, 3, 5, 10));
11var_dump(min(10, 5, 3.5, 2));
12var_dump(min(2, 3.5, 5, 10));
13var_dump(min(10, 5, "3", 2));
14var_dump(min(2, "3", 5, 10));
15var_dump(min(2, 3, "1", 10));
16echo "Check that int not representable as float works:\n";
17var_dump(min(PHP_INT_MAX-1, PHP_INT_MAX, PHP_INT_MAX*2));
18var_dump(min(PHP_INT_MIN+1, PHP_INT_MIN, PHP_INT_MIN*2));
19// Has INF
20var_dump(min(PHP_INT_MAX-1, PHP_INT_MAX, PHP_INT_MAX**20));
21
22echo "Start as float optimisation:\n";
23var_dump(min(10.5, 5.5, 3.5, 2.5));
24var_dump(min(2.5, 3.5, 5.5, 10.5));
25var_dump(min(10.5, 5.5, 3, 2.5));
26var_dump(min(2.5, 3, 5.5, 10.5));
27var_dump(min(10.5, 5.5, "3.5", 2.5));
28var_dump(min(2.5, "3.5", 5.5, 10.5));
29var_dump(min(2.5, 3.5, "1.5", 10.5));
30echo "Check that int not representable as float works:\n";
31var_dump(min(PHP_INT_MAX*2, PHP_INT_MAX, PHP_INT_MAX-1));
32var_dump(min(PHP_INT_MIN*2, PHP_INT_MIN, PHP_INT_MIN+1));
33// Has INF
34var_dump(min(PHP_INT_MAX**20, PHP_INT_MAX, PHP_INT_MAX-1));
35
36?>
37--EXPECT--
38Start as int optimisation:
39int(2)
40int(2)
41int(2)
42int(2)
43int(2)
44int(2)
45string(1) "1"
46Check that int not representable as float works:
47int(9223372036854775806)
48float(-1.8446744073709552E+19)
49int(9223372036854775806)
50Start as float optimisation:
51float(2.5)
52float(2.5)
53float(2.5)
54float(2.5)
55float(2.5)
56float(2.5)
57string(3) "1.5"
58Check that int not representable as float works:
59int(9223372036854775806)
60float(-1.8446744073709552E+19)
61int(9223372036854775806)
62