summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/udiv.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/jit-test/tests/wasm/udiv.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/jit-test/tests/wasm/udiv.js')
-rw-r--r--js/src/jit-test/tests/wasm/udiv.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/udiv.js b/js/src/jit-test/tests/wasm/udiv.js
new file mode 100644
index 0000000000..446f23c202
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/udiv.js
@@ -0,0 +1,68 @@
+function test_i32_udiv_n2() {
+ return wasmEvalText(
+ `(module
+ (type (;0;) (func (param i32) (result i32)))
+ (func (;0;) (type 0) (param i32) (result i32)
+ local.get 0
+ i32.const -2
+ i32.div_u)
+ (export "main" (func 0)))`
+ ).exports["main"];
+}
+function test_i32_udiv_n1() {
+ return wasmEvalText(
+ `(module
+ (type (;0;) (func (param i32) (result i32)))
+ (func (;0;) (type 0) (param i32) (result i32)
+ local.get 0
+ i32.const -1
+ i32.div_u)
+ (export "main" (func 0)))`
+ ).exports["main"];
+}
+function test_i32_udiv_p2() {
+ return wasmEvalText(
+ `(module
+ (type (;0;) (func (param i32) (result i32)))
+ (func (;0;) (type 0) (param i32) (result i32)
+ local.get 0
+ i32.const 2
+ i32.div_u)
+ (export "main" (func 0)))`
+ ).exports["main"];
+}
+function test_i32_udiv_p1() {
+ return wasmEvalText(
+ `(module
+ (type (;0;) (func (param i32) (result i32)))
+ (func (;0;) (type 0) (param i32) (result i32)
+ local.get 0
+ i32.const 1
+ i32.div_u)
+ (export "main" (func 0)))`
+ ).exports["main"];
+}
+
+let udiv_p1 = test_i32_udiv_p1();
+assertEq(udiv_p1(1), 1);
+assertEq(udiv_p1(2), 2);
+assertEq(udiv_p1(0x7fffffff), 0x7fffffff);
+assertEq(udiv_p1(-1), -1); // results are converted to i32.
+
+let udiv_p2 = test_i32_udiv_p2();
+assertEq(udiv_p2(1), 0);
+assertEq(udiv_p2(2), 1);
+assertEq(udiv_p2(0x7fffffff), 0x7fffffff >> 1);
+assertEq(udiv_p2(-1), 0x7fffffff); // -1 is converted to u32.
+
+let udiv_n1 = test_i32_udiv_n1();
+assertEq(udiv_n1(1), 0);
+assertEq(udiv_n1(2), 0);
+assertEq(udiv_n1(0x7fffffff), 0);
+assertEq(udiv_n1(-1), 1);
+
+let udiv_n2 = test_i32_udiv_n2();
+assertEq(udiv_n2(1), 0);
+assertEq(udiv_n2(2), 0);
+assertEq(udiv_n2(0x7fffffff), 0);
+assertEq(udiv_n2(-1), 1);