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/ion/mathSign.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/ion/mathSign.js')
-rw-r--r-- | js/src/jit-test/tests/ion/mathSign.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/mathSign.js b/js/src/jit-test/tests/ion/mathSign.js new file mode 100644 index 0000000000..892bcbe63b --- /dev/null +++ b/js/src/jit-test/tests/ion/mathSign.js @@ -0,0 +1,75 @@ +// Test Math.sign() for IonMonkey. +// Requires --ion-eager to enter at the top of each loop. + +var signDITests = [ + [0.49999999999999997, 1], + [0.5, 1], + [1.0, 1], + [1.5, 1], + [792.8, 1], + [-0.1, -1], + [-1.0001, -1], + [-3.14, -1], + [900000000000, 1], + [+0, +0], + [-Infinity, -1], + [Infinity, 1], +]; + +var signDITests_bailout = [ + // Add a few 'double -> int' tests before the bailout. + ...(function*(){ for (var i = 0; i < 50; ++i) yield* signDITests; })(), + + // Trigger bailout for negative zero. + [-0, -0], +]; + +var signDTests = [ + [-0, -0], + [0.49999999999999997, 1], + [0.5, 1], + [1.0, 1], + [1.5, 1], + [792.8, 1], + [-0.1, -1], + [-1.0001, -1], + [-3.14, -1], + [900000000000, 1], + [-0, -0], + [+0, +0], + [-Infinity, -1], + [Infinity, 1], + [NaN, NaN], +]; + +var signITests = [ + [0, 0], + [4, 1], + [-1, -1], + [-7, -1], + [2147483647, 1], + [-2147483648, -1], +]; + +// Typed functions to be compiled by Ion. +function signDI(x) { return Math.sign(x); } +function signDI_bailout(x) { return Math.sign(x); } +function signD(x) { return Math.sign(x); } +function signI(x) { return Math.sign(x); } + +function test() { + // Always run this function in the interpreter. + with ({}) {} + + for (var i = 0; i < signDITests.length; i++) + assertEq(signDI(signDITests[i][0]), signDITests[i][1]); + for (var i = 0; i < signDITests_bailout.length; i++) + assertEq(signDI_bailout(signDITests_bailout[i][0]), signDITests_bailout[i][1]); + for (var i = 0; i < signDTests.length; i++) + assertEq(signD(signDTests[i][0]), signDTests[i][1]); + for (var i = 0; i < signITests.length; i++) + assertEq(signI(signITests[i][0]), signITests[i][1]); +} + +for (var i = 0; i < 40; i++) + test(); |