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/truthiness | |
parent | Initial commit. (diff) | |
download | firefox-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/truthiness')
21 files changed, 781 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/truthiness/equal-null.js b/js/src/jit-test/tests/truthiness/equal-null.js new file mode 100644 index 0000000000..bba6617db4 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/equal-null.js @@ -0,0 +1,37 @@ +function f(v, value) +{ + var b = v == null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +f({}, false); +f({}, false); +f(null, true); +f(null, true); +f(undefined, true); +f(undefined, true); +f(createIsHTMLDDA(), true); +f(createIsHTMLDDA(), true); +f(Object.prototype, false); +f(Object.prototype, false); + +function g(v, value) +{ + var b = v == null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +g({}, false); +g({}, false); + +function h(v, value) +{ + var b = v == null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), true); +h(createIsHTMLDDA(), true); diff --git a/js/src/jit-test/tests/truthiness/equal-undefined.js b/js/src/jit-test/tests/truthiness/equal-undefined.js new file mode 100644 index 0000000000..b807098cb3 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/equal-undefined.js @@ -0,0 +1,37 @@ +function f(v, value) +{ + var b = v == undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +f({}, false); +f({}, false); +f(null, true); +f(null, true); +f(undefined, true); +f(undefined, true); +f(createIsHTMLDDA(), true); +f(createIsHTMLDDA(), true); +f(Object.prototype, false); +f(Object.prototype, false); + +function g(v, value) +{ + var b = v == undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +g({}, false); +g({}, false); + +function h(v, value) +{ + var b = v == undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), true); +h(createIsHTMLDDA(), true); diff --git a/js/src/jit-test/tests/truthiness/if-equal-null.js b/js/src/jit-test/tests/truthiness/if-equal-null.js new file mode 100644 index 0000000000..79fc6f37dd --- /dev/null +++ b/js/src/jit-test/tests/truthiness/if-equal-null.js @@ -0,0 +1,46 @@ +var counterF = 0; + +function f(v, value) +{ + if (v == null) + counterF++; + assertEq(counterF, value, + "failed: " + v + " " + value); +} + +f({}, 0); +f({}, 0); +f(null, 1); +f(null, 2); +f(undefined, 3); +f(undefined, 4); +f(createIsHTMLDDA(), 5); +f(createIsHTMLDDA(), 6); +f(Object.prototype, 6); +f(Object.prototype, 6); + +var counterG = 0; + +function g(v, value) +{ + if (v == null) + counterG++; + assertEq(counterG, value, + "failed: " + v + " " + value); +} + +g({}, 0); +g({}, 0); + +var counterH = 0; + +function h(v, value) +{ + if (v == null) + counterH++; + assertEq(counterH, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), 1); +h(createIsHTMLDDA(), 2); diff --git a/js/src/jit-test/tests/truthiness/if-equal-undefined.js b/js/src/jit-test/tests/truthiness/if-equal-undefined.js new file mode 100644 index 0000000000..9a2284b94c --- /dev/null +++ b/js/src/jit-test/tests/truthiness/if-equal-undefined.js @@ -0,0 +1,46 @@ +var counterF = 0; + +function f(v, value) +{ + if (v == undefined) + counterF++; + assertEq(counterF, value, + "failed: " + v + " " + value); +} + +f({}, 0); +f({}, 0); +f(null, 1); +f(null, 2); +f(undefined, 3); +f(undefined, 4); +f(createIsHTMLDDA(), 5); +f(createIsHTMLDDA(), 6); +f(Object.prototype, 6); +f(Object.prototype, 6); + +var counterG = 0; + +function g(v, value) +{ + if (v == undefined) + counterG++; + assertEq(counterG, value, + "failed: " + v + " " + value); +} + +g({}, 0); +g({}, 0); + +var counterH = 0; + +function h(v, value) +{ + if (v == undefined) + counterH++; + assertEq(counterH, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), 1); +h(createIsHTMLDDA(), 2); diff --git a/js/src/jit-test/tests/truthiness/if-not-equal-null.js b/js/src/jit-test/tests/truthiness/if-not-equal-null.js new file mode 100644 index 0000000000..d0d266042b --- /dev/null +++ b/js/src/jit-test/tests/truthiness/if-not-equal-null.js @@ -0,0 +1,46 @@ +var counterF = 0; + +function f(v, value) +{ + if (v != null) + counterF++; + assertEq(counterF, value, + "failed: " + v + " " + value); +} + +f({}, 1); +f({}, 2); +f(null, 2); +f(null, 2); +f(undefined, 2); +f(undefined, 2); +f(createIsHTMLDDA(), 2); +f(createIsHTMLDDA(), 2); +f(Object.prototype, 3); +f(Object.prototype, 4); + +var counterG = 0; + +function g(v, value) +{ + if (v != null) + counterG++; + assertEq(counterG, value, + "failed: " + v + " " + value); +} + +g({}, 1); +g({}, 2); + +var counterH = 0; + +function h(v, value) +{ + if (v != null) + counterH++; + assertEq(counterH, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), 0); +h(createIsHTMLDDA(), 0); diff --git a/js/src/jit-test/tests/truthiness/if-not-equal-undefined.js b/js/src/jit-test/tests/truthiness/if-not-equal-undefined.js new file mode 100644 index 0000000000..204b8d293e --- /dev/null +++ b/js/src/jit-test/tests/truthiness/if-not-equal-undefined.js @@ -0,0 +1,46 @@ +var counterF = 0; + +function f(v, value) +{ + if (v != undefined) + counterF++; + assertEq(counterF, value, + "failed: " + v + " " + value); +} + +f({}, 1); +f({}, 2); +f(null, 2); +f(null, 2); +f(undefined, 2); +f(undefined, 2); +f(createIsHTMLDDA(), 2); +f(createIsHTMLDDA(), 2); +f(Object.prototype, 3); +f(Object.prototype, 4); + +var counterG = 0; + +function g(v, value) +{ + if (v != undefined) + counterG++; + assertEq(counterG, value, + "failed: " + v + " " + value); +} + +g({}, 1); +g({}, 2); + +var counterH = 0; + +function h(v, value) +{ + if (v != undefined) + counterH++; + assertEq(counterH, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), 0); +h(createIsHTMLDDA(), 0); diff --git a/js/src/jit-test/tests/truthiness/if-strict-equal-null.js b/js/src/jit-test/tests/truthiness/if-strict-equal-null.js new file mode 100644 index 0000000000..f571930ef9 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/if-strict-equal-null.js @@ -0,0 +1,46 @@ +var counterF = 0; + +function f(v, value) +{ + if (v === null) + counterF++; + assertEq(counterF, value, + "failed: " + v + " " + value); +} + +f({}, 0); +f({}, 0); +f(null, 1); +f(null, 2); +f(undefined, 2); +f(undefined, 2); +f(createIsHTMLDDA(), 2); +f(createIsHTMLDDA(), 2); +f(Object.prototype, 2); +f(Object.prototype, 2); + +var counterG = 0; + +function g(v, value) +{ + if (v === null) + counterG++; + assertEq(counterG, value, + "failed: " + v + " " + value); +} + +g({}, 0); +g({}, 0); + +var counterH = 0; + +function h(v, value) +{ + if (v === null) + counterH++; + assertEq(counterH, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), 0); +h(createIsHTMLDDA(), 0); diff --git a/js/src/jit-test/tests/truthiness/if-strict-equal-undefined.js b/js/src/jit-test/tests/truthiness/if-strict-equal-undefined.js new file mode 100644 index 0000000000..670adc4784 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/if-strict-equal-undefined.js @@ -0,0 +1,46 @@ +var counterF = 0; + +function f(v, value) +{ + if (v === undefined) + counterF++; + assertEq(counterF, value, + "failed: " + v + " " + value); +} + +f({}, 0); +f({}, 0); +f(null, 0); +f(null, 0); +f(undefined, 1); +f(undefined, 2); +f(createIsHTMLDDA(), 2); +f(createIsHTMLDDA(), 2); +f(Object.prototype, 2); +f(Object.prototype, 2); + +var counterG = 0; + +function g(v, value) +{ + if (v === undefined) + counterG++; + assertEq(counterG, value, + "failed: " + v + " " + value); +} + +g({}, 0); +g({}, 0); + +var counterH = 0; + +function h(v, value) +{ + if (v === undefined) + counterH++; + assertEq(counterH, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), 0); +h(createIsHTMLDDA(), 0); diff --git a/js/src/jit-test/tests/truthiness/if-strict-not-equal-null.js b/js/src/jit-test/tests/truthiness/if-strict-not-equal-null.js new file mode 100644 index 0000000000..cae48fb213 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/if-strict-not-equal-null.js @@ -0,0 +1,46 @@ +var counterF = 0; + +function f(v, value) +{ + if (v !== null) + counterF++; + assertEq(counterF, value, + "failed: " + v + " " + value); +} + +f({}, 1); +f({}, 2); +f(null, 2); +f(null, 2); +f(undefined, 3); +f(undefined, 4); +f(createIsHTMLDDA(), 5); +f(createIsHTMLDDA(), 6); +f(Object.prototype, 7); +f(Object.prototype, 8); + +var counterG = 0; + +function g(v, value) +{ + if (v !== null) + counterG++; + assertEq(counterG, value, + "failed: " + v + " " + value); +} + +g({}, 1); +g({}, 2); + +var counterH = 0; + +function h(v, value) +{ + if (v !== null) + counterH++; + assertEq(counterH, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), 1); +h(createIsHTMLDDA(), 2); diff --git a/js/src/jit-test/tests/truthiness/if-strict-not-equal-undefined.js b/js/src/jit-test/tests/truthiness/if-strict-not-equal-undefined.js new file mode 100644 index 0000000000..433446fe11 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/if-strict-not-equal-undefined.js @@ -0,0 +1,46 @@ +var counterF = 0; + +function f(v, value) +{ + if (v !== undefined) + counterF++; + assertEq(counterF, value, + "failed: " + v + " " + value); +} + +f({}, 1); +f({}, 2); +f(null, 3); +f(null, 4); +f(undefined, 4); +f(undefined, 4); +f(createIsHTMLDDA(), 5); +f(createIsHTMLDDA(), 6); +f(Object.prototype, 7); +f(Object.prototype, 8); + +var counterG = 0; + +function g(v, value) +{ + if (v !== undefined) + counterG++; + assertEq(counterG, value, + "failed: " + v + " " + value); +} + +g({}, 1); +g({}, 2); + +var counterH = 0; + +function h(v, value) +{ + if (v !== undefined) + counterH++; + assertEq(counterH, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), 1); +h(createIsHTMLDDA(), 2); diff --git a/js/src/jit-test/tests/truthiness/if.js b/js/src/jit-test/tests/truthiness/if.js new file mode 100644 index 0000000000..129df405f9 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/if.js @@ -0,0 +1,24 @@ +function t1(v) +{ + if (v) + return 1; + return 0; +} + +assertEq(t1(createIsHTMLDDA()), 0); +assertEq(t1(createIsHTMLDDA()), 0); +assertEq(t1(createIsHTMLDDA()), 0); + +function t2(v) +{ + if (v) + return 1; + return 0; +} + +assertEq(t2(17), 1); +assertEq(t2(0), 0); +assertEq(t2(-0), 0); +assertEq(t2(createIsHTMLDDA()), 0); +assertEq(t2(createIsHTMLDDA()), 0); +assertEq(t2(createIsHTMLDDA()), 0); diff --git a/js/src/jit-test/tests/truthiness/not-equal-null.js b/js/src/jit-test/tests/truthiness/not-equal-null.js new file mode 100644 index 0000000000..ab6c144bce --- /dev/null +++ b/js/src/jit-test/tests/truthiness/not-equal-null.js @@ -0,0 +1,37 @@ +function f(v, value) +{ + var b = v != null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +f({}, true); +f({}, true); +f(null, false); +f(null, false); +f(undefined, false); +f(undefined, false); +f(createIsHTMLDDA(), false); +f(createIsHTMLDDA(), false); +f(Object.prototype, true); +f(Object.prototype, true); + +function g(v, value) +{ + var b = v != null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +g({}, true); +g({}, true); + +function h(v, value) +{ + var b = v != null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), false); +h(createIsHTMLDDA(), false); diff --git a/js/src/jit-test/tests/truthiness/not-equal-undefined.js b/js/src/jit-test/tests/truthiness/not-equal-undefined.js new file mode 100644 index 0000000000..533cf1f018 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/not-equal-undefined.js @@ -0,0 +1,37 @@ +function f(v, value) +{ + var b = v != undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +f({}, true); +f({}, true); +f(null, false); +f(null, false); +f(undefined, false); +f(undefined, false); +f(createIsHTMLDDA(), false); +f(createIsHTMLDDA(), false); +f(Object.prototype, true); +f(Object.prototype, true); + +function g(v, value) +{ + var b = v != undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +g({}, true); +g({}, true); + +function h(v, value) +{ + var b = v != undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), false); +h(createIsHTMLDDA(), false); diff --git a/js/src/jit-test/tests/truthiness/not.js b/js/src/jit-test/tests/truthiness/not.js new file mode 100644 index 0000000000..58945734a1 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/not.js @@ -0,0 +1,24 @@ +function t1(v) +{ + if (!v) + return 1; + return 0; +} + +assertEq(t1(createIsHTMLDDA()), 1); +assertEq(t1(createIsHTMLDDA()), 1); +assertEq(t1(createIsHTMLDDA()), 1); + +function t2(v) +{ + if (!v) + return 1; + return 0; +} + +assertEq(t2(17), 0); +assertEq(t2(0), 1); +assertEq(t2(-0), 1); +assertEq(t2(createIsHTMLDDA()), 1); +assertEq(t2(createIsHTMLDDA()), 1); +assertEq(t2(createIsHTMLDDA()), 1); diff --git a/js/src/jit-test/tests/truthiness/obj-obj-equal.js b/js/src/jit-test/tests/truthiness/obj-obj-equal.js new file mode 100644 index 0000000000..0800c05432 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/obj-obj-equal.js @@ -0,0 +1,23 @@ +function f(v1, v2, value) +{ + var b = v1 == v2; + assertEq(b, value, + "failed: " + v1 + ", " + v2 + ": " + value); +} + +var obj = {}; +var emul = createIsHTMLDDA(); + +f(obj, obj, true); +f(obj, obj, true); +f(emul, obj, false); +f(emul, obj, false); +f(obj, emul, false); +f(obj, emul, false); +f(Object.prototype, obj, false); +f(Object.prototype, obj, false); +f(emul, emul, true); +f(createIsHTMLDDA(), emul, false); +f(createIsHTMLDDA(), emul, false); +f(emul, createIsHTMLDDA(), false); +f(emul, createIsHTMLDDA(), false); diff --git a/js/src/jit-test/tests/truthiness/obj-obj-not-equal.js b/js/src/jit-test/tests/truthiness/obj-obj-not-equal.js new file mode 100644 index 0000000000..5fb905aaf5 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/obj-obj-not-equal.js @@ -0,0 +1,23 @@ +function f(v1, v2, value) +{ + var b = v1 != v2; + assertEq(b, value, + "failed: " + v1 + ", " + v2 + ": " + value); +} + +var obj = {}; +var emul = createIsHTMLDDA(); + +f(obj, obj, false); +f(obj, obj, false); +f(emul, obj, true); +f(emul, obj, true); +f(obj, emul, true); +f(obj, emul, true); +f(Object.prototype, obj, true); +f(Object.prototype, obj, true); +f(emul, emul, false); +f(createIsHTMLDDA(), emul, true); +f(createIsHTMLDDA(), emul, true); +f(emul, createIsHTMLDDA(), true); +f(emul, createIsHTMLDDA(), true); diff --git a/js/src/jit-test/tests/truthiness/strict-equal-null.js b/js/src/jit-test/tests/truthiness/strict-equal-null.js new file mode 100644 index 0000000000..a20d893332 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/strict-equal-null.js @@ -0,0 +1,37 @@ +function f(v, value) +{ + var b = v === null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +f({}, false); +f({}, false); +f(null, true); +f(null, true); +f(undefined, false); +f(undefined, false); +f(createIsHTMLDDA(), false); +f(createIsHTMLDDA(), false); +f(Object.prototype, false); +f(Object.prototype, false); + +function g(v, value) +{ + var b = v === null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +g({}, false); +g({}, false); + +function h(v, value) +{ + var b = v === null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), false); +h(createIsHTMLDDA(), false); diff --git a/js/src/jit-test/tests/truthiness/strict-equal-undefined.js b/js/src/jit-test/tests/truthiness/strict-equal-undefined.js new file mode 100644 index 0000000000..f58e13698d --- /dev/null +++ b/js/src/jit-test/tests/truthiness/strict-equal-undefined.js @@ -0,0 +1,37 @@ +function f(v, value) +{ + var b = v === undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +f({}, false); +f({}, false); +f(null, false); +f(null, false); +f(undefined, true); +f(undefined, true); +f(createIsHTMLDDA(), false); +f(createIsHTMLDDA(), false); +f(Object.prototype, false); +f(Object.prototype, false); + +function g(v, value) +{ + var b = v === undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +g({}, false); +g({}, false); + +function h(v, value) +{ + var b = v === undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), false); +h(createIsHTMLDDA(), false); diff --git a/js/src/jit-test/tests/truthiness/strict-not-equal-null.js b/js/src/jit-test/tests/truthiness/strict-not-equal-null.js new file mode 100644 index 0000000000..7cab3e7b1c --- /dev/null +++ b/js/src/jit-test/tests/truthiness/strict-not-equal-null.js @@ -0,0 +1,37 @@ +function f(v, value) +{ + var b = v !== null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +f({}, true); +f({}, true); +f(null, false); +f(null, false); +f(undefined, true); +f(undefined, true); +f(createIsHTMLDDA(), true); +f(createIsHTMLDDA(), true); +f(Object.prototype, true); +f(Object.prototype, true); + +function g(v, value) +{ + var b = v !== null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +g({}, true); +g({}, true); + +function h(v, value) +{ + var b = v !== null; + assertEq(b, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), true); +h(createIsHTMLDDA(), true); diff --git a/js/src/jit-test/tests/truthiness/strict-not-equal-undefined.js b/js/src/jit-test/tests/truthiness/strict-not-equal-undefined.js new file mode 100644 index 0000000000..04c8f7702b --- /dev/null +++ b/js/src/jit-test/tests/truthiness/strict-not-equal-undefined.js @@ -0,0 +1,37 @@ +function f(v, value) +{ + var b = v !== undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +f({}, true); +f({}, true); +f(null, true); +f(null, true); +f(undefined, false); +f(undefined, false); +f(createIsHTMLDDA(), true); +f(createIsHTMLDDA(), true); +f(Object.prototype, true); +f(Object.prototype, true); + +function g(v, value) +{ + var b = v !== undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +g({}, true); +g({}, true); + +function h(v, value) +{ + var b = v !== undefined; + assertEq(b, value, + "failed: " + v + " " + value); +} + +h(createIsHTMLDDA(), true); +h(createIsHTMLDDA(), true); diff --git a/js/src/jit-test/tests/truthiness/typeof.js b/js/src/jit-test/tests/truthiness/typeof.js new file mode 100644 index 0000000000..91e281ada3 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/typeof.js @@ -0,0 +1,23 @@ +function t1(v) +{ + return typeof v; +} + +assertEq(t1(createIsHTMLDDA()), "undefined"); +assertEq(t1(createIsHTMLDDA()), "undefined"); +assertEq(t1(createIsHTMLDDA()), "undefined"); + +function t2(v) +{ + return typeof v; +} + +assertEq(t2(17), "number"); +assertEq(t2(0), "number"); +assertEq(t2(-0), "number"); +assertEq(t2(function(){}), "function"); +assertEq(t2({}), "object"); +assertEq(t2(null), "object"); +assertEq(t2(createIsHTMLDDA()), "undefined"); +assertEq(t2(createIsHTMLDDA()), "undefined"); +assertEq(t2(createIsHTMLDDA()), "undefined"); |