diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/wasm/udiv.js | |
parent | Initial commit. (diff) | |
download | firefox-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 '')
-rw-r--r-- | js/src/jit-test/tests/wasm/udiv.js | 68 |
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); |