diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/truthiness | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
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 000000000..2b7d58286 --- /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(objectEmulatingUndefined(), true); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), true); +h(objectEmulatingUndefined(), 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 000000000..5d76f93a1 --- /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(objectEmulatingUndefined(), true); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), true); +h(objectEmulatingUndefined(), 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 000000000..f487ea349 --- /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(objectEmulatingUndefined(), 5); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), 1); +h(objectEmulatingUndefined(), 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 000000000..fd7d2abe4 --- /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(objectEmulatingUndefined(), 5); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), 1); +h(objectEmulatingUndefined(), 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 000000000..a31aa78ee --- /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(objectEmulatingUndefined(), 2); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), 0); +h(objectEmulatingUndefined(), 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 000000000..583959d36 --- /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(objectEmulatingUndefined(), 2); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), 0); +h(objectEmulatingUndefined(), 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 000000000..1c9e829fe --- /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(objectEmulatingUndefined(), 2); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), 0); +h(objectEmulatingUndefined(), 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 000000000..04ea4ee52 --- /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(objectEmulatingUndefined(), 2); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), 0); +h(objectEmulatingUndefined(), 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 000000000..6facef816 --- /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(objectEmulatingUndefined(), 5); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), 1); +h(objectEmulatingUndefined(), 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 000000000..d75caae48 --- /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(objectEmulatingUndefined(), 5); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), 1); +h(objectEmulatingUndefined(), 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 000000000..347f9c838 --- /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(objectEmulatingUndefined()), 0); +assertEq(t1(objectEmulatingUndefined()), 0); +assertEq(t1(objectEmulatingUndefined()), 0); + +function t2(v) +{ + if (v) + return 1; + return 0; +} + +assertEq(t2(17), 1); +assertEq(t2(0), 0); +assertEq(t2(-0), 0); +assertEq(t2(objectEmulatingUndefined()), 0); +assertEq(t2(objectEmulatingUndefined()), 0); +assertEq(t2(objectEmulatingUndefined()), 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 000000000..ffb62e1d6 --- /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(objectEmulatingUndefined(), false); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), false); +h(objectEmulatingUndefined(), 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 000000000..a913a67f2 --- /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(objectEmulatingUndefined(), false); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), false); +h(objectEmulatingUndefined(), 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 000000000..4adccdaff --- /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(objectEmulatingUndefined()), 1); +assertEq(t1(objectEmulatingUndefined()), 1); +assertEq(t1(objectEmulatingUndefined()), 1); + +function t2(v) +{ + if (!v) + return 1; + return 0; +} + +assertEq(t2(17), 0); +assertEq(t2(0), 1); +assertEq(t2(-0), 1); +assertEq(t2(objectEmulatingUndefined()), 1); +assertEq(t2(objectEmulatingUndefined()), 1); +assertEq(t2(objectEmulatingUndefined()), 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 000000000..77c6683f1 --- /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 = objectEmulatingUndefined(); + +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(objectEmulatingUndefined(), emul, false); +f(objectEmulatingUndefined(), emul, false); +f(emul, objectEmulatingUndefined(), false); +f(emul, objectEmulatingUndefined(), 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 000000000..f1b2d7c19 --- /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 = objectEmulatingUndefined(); + +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(objectEmulatingUndefined(), emul, true); +f(objectEmulatingUndefined(), emul, true); +f(emul, objectEmulatingUndefined(), true); +f(emul, objectEmulatingUndefined(), 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 000000000..00062d16d --- /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(objectEmulatingUndefined(), false); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), false); +h(objectEmulatingUndefined(), 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 000000000..2535cd06f --- /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(objectEmulatingUndefined(), false); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), false); +h(objectEmulatingUndefined(), 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 000000000..9352ae99d --- /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(objectEmulatingUndefined(), true); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), true); +h(objectEmulatingUndefined(), 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 000000000..21790b23e --- /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(objectEmulatingUndefined(), true); +f(objectEmulatingUndefined(), 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(objectEmulatingUndefined(), true); +h(objectEmulatingUndefined(), 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 000000000..4b295b318 --- /dev/null +++ b/js/src/jit-test/tests/truthiness/typeof.js @@ -0,0 +1,23 @@ +function t1(v) +{ + return typeof v; +} + +assertEq(t1(objectEmulatingUndefined()), "undefined"); +assertEq(t1(objectEmulatingUndefined()), "undefined"); +assertEq(t1(objectEmulatingUndefined()), "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(objectEmulatingUndefined()), "undefined"); +assertEq(t2(objectEmulatingUndefined()), "undefined"); +assertEq(t2(objectEmulatingUndefined()), "undefined"); |