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/tests/ecma_6/Map | |
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/tests/ecma_6/Map')
-rw-r--r-- | js/src/tests/ecma_6/Map/NaN-as-key.js | 55 | ||||
-rw-r--r-- | js/src/tests/ecma_6/Map/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/ecma_6/Map/constructor-iterator-primitive.js | 34 | ||||
-rw-r--r-- | js/src/tests/ecma_6/Map/forEach-selfhosted-behavior.js | 51 | ||||
-rw-r--r-- | js/src/tests/ecma_6/Map/getter-name.js | 10 | ||||
-rw-r--r-- | js/src/tests/ecma_6/Map/iterable.js | 28 | ||||
-rw-r--r-- | js/src/tests/ecma_6/Map/shell.js | 0 | ||||
-rw-r--r-- | js/src/tests/ecma_6/Map/symbols.js | 33 |
8 files changed, 211 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Map/NaN-as-key.js b/js/src/tests/ecma_6/Map/NaN-as-key.js new file mode 100644 index 000000000..6fa5ee67e --- /dev/null +++ b/js/src/tests/ecma_6/Map/NaN-as-key.js @@ -0,0 +1,55 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 722260; +var summary = 'All NaNs must be treated as identical keys for Map'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +/* Avoid constant-folding that would happen were |undefined| to be used. */ +var key = -/a/g.missingProperty; + +var m = new Map(); +m.set(key, 17); +assertEq(m.get(key), 17); +assertEq(m.get(-key), 17); +assertEq(m.get(NaN), 17); + +m.delete(-key); +assertEq(m.has(key), false); +assertEq(m.has(-key), false); +assertEq(m.has(NaN), false); + +m.set(-key, 17); +assertEq(m.get(key), 17); +assertEq(m.get(-key), 17); +assertEq(m.get(NaN), 17); + +m.delete(NaN); +assertEq(m.has(key), false); +assertEq(m.has(-key), false); +assertEq(m.has(NaN), false); + +m.set(NaN, 17); +assertEq(m.get(key), 17); +assertEq(m.get(-key), 17); +assertEq(m.get(NaN), 17); + +m.delete(key); +assertEq(m.has(key), false); +assertEq(m.has(-key), false); +assertEq(m.has(NaN), false); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/ecma_6/Map/browser.js b/js/src/tests/ecma_6/Map/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_6/Map/browser.js diff --git a/js/src/tests/ecma_6/Map/constructor-iterator-primitive.js b/js/src/tests/ecma_6/Map/constructor-iterator-primitive.js new file mode 100644 index 000000000..e1fff5c3c --- /dev/null +++ b/js/src/tests/ecma_6/Map/constructor-iterator-primitive.js @@ -0,0 +1,34 @@ +var BUGNUMBER = 1021835; +var summary = "Returning non-object from @@iterator should throw"; + +print(BUGNUMBER + ": " + summary); + +let ctors = [ + Map, + Set, + WeakMap, + WeakSet +]; + +let primitives = [ + 1, + true, + undefined, + null, + "foo", + Symbol.iterator +]; + +for (let ctor of ctors) { + for (let primitive of primitives) { + let arg = { + [Symbol.iterator]() { + return primitive; + } + }; + assertThrowsInstanceOf(() => new ctor(arg), TypeError); + } +} + +if (typeof reportCompare === "function") + reportCompare(0, 0); diff --git a/js/src/tests/ecma_6/Map/forEach-selfhosted-behavior.js b/js/src/tests/ecma_6/Map/forEach-selfhosted-behavior.js new file mode 100644 index 000000000..ed4d8b57f --- /dev/null +++ b/js/src/tests/ecma_6/Map/forEach-selfhosted-behavior.js @@ -0,0 +1,51 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 987243; +var summary = "Don't use .call(...) in the self-hosted Map.prototype.forEach"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var functionCall = Function.prototype.call; + +function throwSyntaxError() +{ + throw new SyntaxError("Function.prototype.call incorrectly called"); +} + +function lalala() {} + +Function.prototype.call = throwSyntaxError; + +new Map().forEach(throwSyntaxError); +new Map([[1, 2]]).forEach(lalala); +new Map([[1, 2], [3, 4]]).forEach(lalala); + +Function.prototype.call = function() { this.set(42, "fnord"); }; + +new Map().forEach(throwSyntaxError); +new Map([[1, 2]]).forEach(lalala); +new Map([[1, 2], [3, 4]]).forEach(lalala); + +var callCount = 0; +Function.prototype.call = function() { callCount++; }; + +new Map().forEach(throwSyntaxError); +new Map([[1, 2]]).forEach(lalala); +new Map([[1, 2], [3, 4]]).forEach(lalala); + +assertEq(callCount, 0); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); diff --git a/js/src/tests/ecma_6/Map/getter-name.js b/js/src/tests/ecma_6/Map/getter-name.js new file mode 100644 index 000000000..08f7890c7 --- /dev/null +++ b/js/src/tests/ecma_6/Map/getter-name.js @@ -0,0 +1,10 @@ +var BUGNUMBER = 1180290; +var summary = 'Map getters should have get prefix'; + +print(BUGNUMBER + ": " + summary); + +assertEq(Object.getOwnPropertyDescriptor(Map, Symbol.species).get.name, "get [Symbol.species]"); +assertEq(Object.getOwnPropertyDescriptor(Map.prototype, "size").get.name, "get size"); + +if (typeof reportCompare === 'function') + reportCompare(true, true); diff --git a/js/src/tests/ecma_6/Map/iterable.js b/js/src/tests/ecma_6/Map/iterable.js new file mode 100644 index 000000000..cf6b7228a --- /dev/null +++ b/js/src/tests/ecma_6/Map/iterable.js @@ -0,0 +1,28 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ */ + +let length; +let iterable = { + [Symbol.iterator]() { return this; }, + next() { length = arguments.length; return {done: true}; } +}; + +new Map(iterable); +// ensure no arguments are passed to next() during construction (Bug 1197095) +assertEq(length, 0); + +let typeofThis; +Object.defineProperty(Number.prototype, Symbol.iterator, { + value() { + "use strict"; + typeofThis = typeof this; + return { next() { return {done: true}; } }; + } +}); + +new Map(0); +// ensure that iterable objects retain their type (Bug 1197094) +assertEq(typeofThis, "number"); + +if (typeof reportCompare === "function") + reportCompare(0, 0); diff --git a/js/src/tests/ecma_6/Map/shell.js b/js/src/tests/ecma_6/Map/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_6/Map/shell.js diff --git a/js/src/tests/ecma_6/Map/symbols.js b/js/src/tests/ecma_6/Map/symbols.js new file mode 100644 index 000000000..30589a973 --- /dev/null +++ b/js/src/tests/ecma_6/Map/symbols.js @@ -0,0 +1,33 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ */ + +var m = new Map; + +// Symbols can be Map keys. +var sym = Symbol(); +m.set(sym, "zero"); +assertEq(m.has(sym), true); +assertEq(m.get(sym), "zero"); +assertEq(m.has(Symbol()), false); +assertEq(m.get(Symbol()), undefined); +assertEq([...m][0][0], sym); +m.set(sym, "replaced"); +assertEq(m.get(sym), "replaced"); +m.delete(sym); +assertEq(m.has(sym), false); +assertEq(m.size, 0); + +// Symbols returned by Symbol.for() can be Map keys. +for (var word of "that that is is that that is not is not is that not it".split(' ')) { + sym = Symbol.for(word); + m.set(sym, (m.get(sym) || 0) + 1); +} +assertDeepEq([...m], [ + [Symbol.for("that"), 5], + [Symbol.for("is"), 5], + [Symbol.for("not"), 3], + [Symbol.for("it"), 1] +]); + +if (typeof reportCompare === "function") + reportCompare(0, 0); |