diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/jaeger/inline/mathRound.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/jaeger/inline/mathRound.js')
-rw-r--r-- | js/src/jit-test/tests/jaeger/inline/mathRound.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/jaeger/inline/mathRound.js b/js/src/jit-test/tests/jaeger/inline/mathRound.js new file mode 100644 index 0000000000..60a59e2020 --- /dev/null +++ b/js/src/jit-test/tests/jaeger/inline/mathRound.js @@ -0,0 +1,41 @@ + +assertEq(Math.round(3.14), 3); +assertEq(Math.round(0.5), 1); +assertEq(Math.round(-0), -0); +assertEq(Math.round(0), 0); +assertEq(Math.round(-1.03), -1); +assertEq(Math.round(2147483649), 2147483649); +assertEq(Math.round(2147483647.5), 2147483648); +assertEq(Math.floor(2147483647.1), 2147483647); + +/* Inferred as round(double). */ +function round1(x) { + return Math.round(x); +} +assertEq(round1(10.3), 10); +assertEq(round1(-3.14), -3); +assertEq(round1(-3.5), -3); +assertEq(round1(-3.6), -4); +assertEq(round1(3.5), 4); +assertEq(round1(3.6), 4); +assertEq(round1(0), 0); +assertEq(round1(-0), -0); // recompile to return double +assertEq(round1(12345), 12345); +assertEq(round1(654.6), 655); + +/* Inferred as round(double). */ +function round2(x) { + return Math.round(x); +} +assertEq(round2(1234.5), 1235); +assertEq(round2(NaN), NaN); // recompile to return double +assertEq(round2(4.6), 5); + +/* Inferred as round(int). */ +function round3(x) { + return Math.round(x); +} +assertEq(round3(4), 4); +assertEq(round3(-5), -5); +assertEq(round3(0), 0); + |