summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/jaeger/inline/mathRound.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/jaeger/inline/mathRound.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
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.js41
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);
+