summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/symbol
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/symbol
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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/symbol')
-rw-r--r--js/src/jit-test/tests/symbol/bug-1033856.js6
-rw-r--r--js/src/jit-test/tests/symbol/not.js13
-rw-r--r--js/src/jit-test/tests/symbol/toNumber-2.js14
-rw-r--r--js/src/jit-test/tests/symbol/toNumber.js53
-rw-r--r--js/src/jit-test/tests/symbol/toString.js11
-rw-r--r--js/src/jit-test/tests/symbol/truthiness.js13
-rw-r--r--js/src/jit-test/tests/symbol/typed-arrays.js29
-rw-r--r--js/src/jit-test/tests/symbol/typeof.js9
8 files changed, 148 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/symbol/bug-1033856.js b/js/src/jit-test/tests/symbol/bug-1033856.js
new file mode 100644
index 000000000..18f80ac20
--- /dev/null
+++ b/js/src/jit-test/tests/symbol/bug-1033856.js
@@ -0,0 +1,6 @@
+function f(x, y) {
+ return x == y;
+}
+f(1.1, 2.2);
+for (var i=0; i<5; i++)
+ f(1, Symbol());
diff --git a/js/src/jit-test/tests/symbol/not.js b/js/src/jit-test/tests/symbol/not.js
new file mode 100644
index 000000000..7237b0b36
--- /dev/null
+++ b/js/src/jit-test/tests/symbol/not.js
@@ -0,0 +1,13 @@
+for (var i = 0; i < 9; i++)
+ assertEq(!Symbol(), false, "symbols are truthy");
+
+var a = [0, 0, 0, 0, 0, Symbol(), Symbol()];
+var b = [];
+function f(i, v) {
+ b[i] = !v;
+}
+for (var i = 0; i < a.length; i++)
+ f(i, a[i]);
+assertEq(b[b.length - 3], true);
+assertEq(b[b.length - 2], false);
+assertEq(b[b.length - 1], false);
diff --git a/js/src/jit-test/tests/symbol/toNumber-2.js b/js/src/jit-test/tests/symbol/toNumber-2.js
new file mode 100644
index 000000000..05a3224e9
--- /dev/null
+++ b/js/src/jit-test/tests/symbol/toNumber-2.js
@@ -0,0 +1,14 @@
+// |jit-test| error: ReferenceError
+function eq(e, a) {
+ passed = (a == e);
+}
+function f(e, a) {
+ fail();
+ eq(e, a);
+}
+try {
+ f();
+} catch (exc1) {}
+eq(.1, .1);
+var sym = Symbol("method");
+evaluate("f(test, sym, 0)", {isRunOnce:true});
diff --git a/js/src/jit-test/tests/symbol/toNumber.js b/js/src/jit-test/tests/symbol/toNumber.js
new file mode 100644
index 000000000..4677acbeb
--- /dev/null
+++ b/js/src/jit-test/tests/symbol/toNumber.js
@@ -0,0 +1,53 @@
+load(libdir + "asserts.js");
+
+var sym = Symbol();
+
+function add2(x) {
+ return x + 2;
+}
+for (var i = 0; i < 9; i++)
+ assertThrowsInstanceOf(() => add2(sym), TypeError);
+
+function sqr(x) {
+ return x * x;
+}
+for (var i = 0; i < 9; i++)
+ assertThrowsInstanceOf(() => sqr(sym), TypeError);
+
+function bit_or(x) {
+ return x | x;
+}
+for (var i = 0; i < 9; i++)
+ assertThrowsInstanceOf(() => bit_or(sym), TypeError);
+
+function bit_not(x) {
+ return ~x;
+}
+for (var i = 0; i < 9; i++)
+ assertThrowsInstanceOf(() => bit_not(sym), TypeError);
+
+function plus(x) {
+ return +x;
+}
+for (var i = 0; i < 9; i++)
+ assertThrowsInstanceOf(() => plus(sym), TypeError);
+
+function f(a, b) {
+ return a + b;
+}
+
+function testPoly() {
+ assertEq(f(20, 30), 50);
+ assertEq(f("one", "two"), "onetwo");
+ assertThrowsInstanceOf(() => f(Symbol("one"), Symbol("two")), TypeError);
+ assertThrowsInstanceOf(() => f(Symbol("14"), 14), TypeError);
+ assertThrowsInstanceOf(() => f(Symbol("14"), 13.719), TypeError);
+ assertThrowsInstanceOf(() => f(14, Symbol("14")), TypeError);
+ assertThrowsInstanceOf(() => f(13.719, Symbol("14")), TypeError);
+}
+
+for (var i = 0; i < 9; i++)
+ testPoly();
+
+for (var i = 0; i < 9; i++)
+ assertThrowsInstanceOf(() => assertEq(f(Symbol("14"), "40"), NaN), TypeError);
diff --git a/js/src/jit-test/tests/symbol/toString.js b/js/src/jit-test/tests/symbol/toString.js
new file mode 100644
index 000000000..764ea7aab
--- /dev/null
+++ b/js/src/jit-test/tests/symbol/toString.js
@@ -0,0 +1,11 @@
+// ToString(symbol) throws a TypeError.
+
+var N = 10, obj, hits = 0;
+for (var i = 0; i < N; i++) {
+ try {
+ obj = new String(Symbol());
+ } catch (exc) {
+ hits++;
+ }
+}
+assertEq(hits, N);
diff --git a/js/src/jit-test/tests/symbol/truthiness.js b/js/src/jit-test/tests/symbol/truthiness.js
new file mode 100644
index 000000000..a672158d6
--- /dev/null
+++ b/js/src/jit-test/tests/symbol/truthiness.js
@@ -0,0 +1,13 @@
+for (var i = 0; i < 9; i++)
+ assertEq(Symbol() ? 1 : 0, 1, "symbols are truthy");
+
+var a = [0, 0, 0, 0, 0, Symbol(), Symbol()];
+var b = [];
+function f(i, v) {
+ b[i] = v ? "yes" : "no";
+}
+for (var i = 0; i < a.length; i++)
+ f(i, a[i]);
+assertEq(b[b.length - 3], "no");
+assertEq(b[b.length - 2], "yes");
+assertEq(b[b.length - 1], "yes");
diff --git a/js/src/jit-test/tests/symbol/typed-arrays.js b/js/src/jit-test/tests/symbol/typed-arrays.js
new file mode 100644
index 000000000..005eec09a
--- /dev/null
+++ b/js/src/jit-test/tests/symbol/typed-arrays.js
@@ -0,0 +1,29 @@
+load(libdir + "asserts.js");
+
+var LENGTH = 1024, SYMBOL_INDEX = 999;
+
+var big = [];
+for (var i = 0; i < LENGTH; i++)
+ big[i] = (i === SYMBOL_INDEX ? Symbol.for("comet") : i);
+
+var progress;
+function copy(arr, big) {
+ for (var i = 0; i < LENGTH; i++) {
+ arr[i] = big[i];
+ progress = i;
+ }
+}
+
+for (var T of [Uint8Array, Uint8ClampedArray, Int16Array, Float32Array]) {
+ // Typed array constructors convert symbols using ToNumber, which throws.
+ assertThrowsInstanceOf(() => new T(big), TypeError);
+
+ // Element assignment does the same.
+ var arr = new T(big.length);
+ for (var k = 0; k < 3; k++) {
+ progress = -1;
+ assertThrowsInstanceOf(() => copy(arr, big), TypeError);
+ assertEq(progress, SYMBOL_INDEX - 1);
+ assertEq(arr[SYMBOL_INDEX], 0);
+ }
+}
diff --git a/js/src/jit-test/tests/symbol/typeof.js b/js/src/jit-test/tests/symbol/typeof.js
new file mode 100644
index 000000000..d2c7d51cf
--- /dev/null
+++ b/js/src/jit-test/tests/symbol/typeof.js
@@ -0,0 +1,9 @@
+var a = [0, 0, 0, 0, 0, Symbol(), Symbol()];
+var b = [];
+function f(i, v) {
+ b[i] = typeof v;
+}
+for (var i = 0; i < a.length; i++)
+ f(i, a[i]);
+assertEq(b[b.length - 2], "symbol");
+assertEq(b[b.length - 1], "symbol");