summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Math/imul/results.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Math/imul/results.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Math/imul/results.js')
-rw-r--r--js/src/tests/test262/built-ins/Math/imul/results.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Math/imul/results.js b/js/src/tests/test262/built-ins/Math/imul/results.js
new file mode 100644
index 0000000000..f67171191a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/imul/results.js
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 The V8 Project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-math.imul
+description: >
+ Return results
+info: |
+ Math.imul ( x, y )
+
+ 1. Let a be ToUint32(x).
+ 2. Let b be ToUint32(y).
+ 3. Let product be (a × b) modulo 232.
+ 4. If product ≥ 231, return product - 232; otherwise return product.
+---*/
+
+assert.sameValue(Math.imul(2, 4), 8, "(2, 4)");
+assert.sameValue(Math.imul(-1, 8), -8, "(-1, 8)");
+assert.sameValue(Math.imul(-2, -2), 4, "(-2, -2)");
+assert.sameValue(Math.imul(0xffffffff, 5), -5, "(0xffffffff, 5)");
+assert.sameValue(Math.imul(0xfffffffe, 5), -10, "(0xfffffffe, 5)");
+
+assert.sameValue(Math.imul(-0, 7), 0);
+assert.sameValue(Math.imul(7, -0), 0);
+
+assert.sameValue(Math.imul(0.1, 7), 0);
+assert.sameValue(Math.imul(7, 0.1), 0);
+assert.sameValue(Math.imul(0.9, 7), 0);
+assert.sameValue(Math.imul(7, 0.9), 0);
+assert.sameValue(Math.imul(1.1, 7), 7);
+assert.sameValue(Math.imul(7, 1.1), 7);
+assert.sameValue(Math.imul(1.9, 7), 7);
+assert.sameValue(Math.imul(7, 1.9), 7);
+
+assert.sameValue(Math.imul(1073741824, 7), -1073741824);
+assert.sameValue(Math.imul(7, 1073741824), -1073741824);
+assert.sameValue(Math.imul(1073741824, 1073741824), 0);
+
+assert.sameValue(Math.imul(-1073741824, 7), 1073741824);
+assert.sameValue(Math.imul(7, -1073741824), 1073741824);
+assert.sameValue(Math.imul(-1073741824, -1073741824), 0);
+
+assert.sameValue(Math.imul(2147483648, 7), -2147483648);
+assert.sameValue(Math.imul(7, 2147483648), -2147483648);
+assert.sameValue(Math.imul(2147483648, 2147483648), 0);
+
+assert.sameValue(Math.imul(-2147483648, 7), -2147483648);
+assert.sameValue(Math.imul(7, -2147483648), -2147483648);
+assert.sameValue(Math.imul(-2147483648, -2147483648), 0);
+
+assert.sameValue(Math.imul(2147483647, 7), 2147483641);
+assert.sameValue(Math.imul(7, 2147483647), 2147483641);
+assert.sameValue(Math.imul(2147483647, 2147483647), 1);
+
+assert.sameValue(Math.imul(65536, 65536), 0);
+assert.sameValue(Math.imul(65535, 65536), -65536);
+assert.sameValue(Math.imul(65536, 65535), -65536);
+assert.sameValue(Math.imul(65535, 65535), -131071);
+
+reportCompare(0, 0);