diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/MapIteratorPrototype | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/MapIteratorPrototype')
15 files changed, 476 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/Symbol.toStringTag.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/Symbol.toStringTag.js new file mode 100644 index 0000000000..d7487e38cf --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/Symbol.toStringTag.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.5.2.2 +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + "Map Iterator". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.iterator, Symbol.toStringTag] +---*/ + +var MapIteratorProto = Object.getPrototypeOf(new Map()[Symbol.iterator]()); + +assert.sameValue('Map Iterator', MapIteratorProto[Symbol.toStringTag]); + +verifyNotEnumerable(MapIteratorProto, Symbol.toStringTag); +verifyNotWritable(MapIteratorProto, Symbol.toStringTag); +verifyConfigurable(MapIteratorProto, Symbol.toStringTag); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/browser.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/browser.js diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/browser.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/browser.js diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots-map.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots-map.js new file mode 100644 index 0000000000..73aafb2b94 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots-map.js @@ -0,0 +1,41 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.5.2.1 +description: > + Throws a TypeError if `this` does not have all of the internal slots of a Map + Iterator Instance. +info: | + %MapIteratorPrototype%.next ( ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have all of the internal slots of a Map Iterator Instance + (23.1.5.3), throw a TypeError exception. + ... +features: [Symbol.iterator] +---*/ + +var map = new Map([[1, 11], [2, 22]]); + +var iterator = map[Symbol.iterator](); +assert.throws(TypeError, function() { + iterator.next.call(map); +}); + +iterator = map.entries(); +assert.throws(TypeError, function() { + iterator.next.call(map); +}); + +iterator = map.keys(); +assert.throws(TypeError, function() { + iterator.next.call(map); +}); + +iterator = map.values(); +assert.throws(TypeError, function() { + iterator.next.call(map); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots.js new file mode 100644 index 0000000000..9e89de3e35 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots.js @@ -0,0 +1,44 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.5.2.1 +description: > + Throws a TypeError if `this` does not have all of the internal slots of a Map + Iterator Instance. +info: | + %MapIteratorPrototype%.next ( ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have all of the internal slots of a Map Iterator Instance + (23.1.5.3), throw a TypeError exception. + ... +features: [Symbol.iterator] +---*/ + +var map = new Map([[1, 11], [2, 22]]); + +var iterator = map[Symbol.iterator](); +assert.throws(TypeError, function() { + iterator.next.call({}); +}); + +iterator = map.entries(); +assert.throws(TypeError, function() { + iterator.next.call({}); +}); + +iterator = map.keys(); +assert.throws(TypeError, function() { + iterator.next.call({}); +}); + +iterator = map.values(); +assert.throws(TypeError, function() { + iterator.next.call({}); +}); + +// does not throw an Error +iterator.next.call(map[Symbol.iterator]()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/iteration-mutable.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/iteration-mutable.js new file mode 100644 index 0000000000..bbb332bdd2 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/iteration-mutable.js @@ -0,0 +1,54 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.3.12 +description: > + When an item is added to the map after the iterator is created but before + the iterator is "done" (as defined by 23.1.5.2.1), the new item should be + accessible via iteration. When an item is added to the map after the + iterator is "done", the new item should not be accessible via iteration. +features: [Symbol.iterator] +---*/ + +var map = new Map(); +map.set(1, 11); +map.set(2, 22); + +var iterator = map[Symbol.iterator](); +var result; + +result = iterator.next(); +assert.sameValue(result.value[0], 1, 'First result `value` (map key)'); +assert.sameValue(result.value[1], 11, 'First result `value` (map value)'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +map.set(3, 33); + +result = iterator.next(); +assert.sameValue(result.value[0], 2, 'Second result `value` (map key)'); +assert.sameValue(result.value[1], 22, 'Second result `value` (map value)'); +assert.sameValue(result.value.length, 2, 'Second result `value` (length)'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value[0], 3, 'Third result `value` (map key)'); +assert.sameValue(result.value[1], 33, 'Third result `value` (map value)'); +assert.sameValue(result.value.length, 2, 'Third result `value` (length)'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +map.set(4, 44); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/iteration.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/iteration.js new file mode 100644 index 0000000000..fcd223704e --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/iteration.js @@ -0,0 +1,49 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.3.12 +description: > + The method should return a valid iterator with the context as the + IteratedObject. +features: [Symbol.iterator] +---*/ + +var map = new Map(); +map.set(1, 11); +map.set(2, 22); +map.set(3, 33); + +var iterator = map[Symbol.iterator](); +var result; + +result = iterator.next(); +assert.sameValue(result.value[0], 1, 'First result `value` (map key)'); +assert.sameValue(result.value[1], 11, 'First result `value` (map value)'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value[0], 2, 'Second result `value` (map key)'); +assert.sameValue(result.value[1], 22, 'Second result `value` (map value)'); +assert.sameValue(result.value.length, 2, 'Second result `value` (length)'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value[0], 3, 'Third result `value` (map key)'); +assert.sameValue(result.value[1], 33, 'Third result `value` (map value)'); +assert.sameValue(result.value.length, 2, 'Third result `value` (length)'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/length.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/length.js new file mode 100644 index 0000000000..7617371899 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 23.1.5.2.1 +description: > + %MapIteratorPrototype%.next.length is 0. +info: | + %MapIteratorPrototype%.next ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +var MapIteratorProto = Object.getPrototypeOf(new Map().values()); + +assert.sameValue(MapIteratorProto.next.length, 0); + +verifyNotEnumerable(MapIteratorProto.next, "length"); +verifyNotWritable(MapIteratorProto.next, "length"); +verifyConfigurable(MapIteratorProto.next, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/name.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/name.js new file mode 100644 index 0000000000..5666f8ecc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/name.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 23.1.5.2.1 +description: > + %MapIteratorPrototype%.next.name is "next". +info: | + %MapIteratorPrototype%.next ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +var MapIteratorProto = Object.getPrototypeOf(new Map().values()); + +assert.sameValue(MapIteratorProto.next.name, "next"); + +verifyNotEnumerable(MapIteratorProto.next, "name"); +verifyNotWritable(MapIteratorProto.next, "name"); +verifyConfigurable(MapIteratorProto.next, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/shell.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/shell.js diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-entries.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-entries.js new file mode 100644 index 0000000000..b87456f307 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-entries.js @@ -0,0 +1,50 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.5.2.1 +description: > + Throws a TypeError if `this` value is not an Object. +info: | + From Map.prototype.entries() + + %MapIteratorPrototype%.next ( ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +features: + - Symbol + - Symbol.iterator +---*/ + +var map = new Map([[1, 11], [2, 22]]); +var iterator = map.entries(); + +assert.throws(TypeError, function() { + iterator.next.call(false); +}); + +assert.throws(TypeError, function() { + iterator.next.call(1); +}); + +assert.throws(TypeError, function() { + iterator.next.call(''); +}); + +assert.throws(TypeError, function() { + iterator.next.call(undefined); +}); + +assert.throws(TypeError, function() { + iterator.next.call(null); +}); + +assert.throws(TypeError, function() { + iterator.next.call(Symbol()); +}); + +// does not throw an Error +iterator.next.call(map[Symbol.iterator]()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-keys.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-keys.js new file mode 100644 index 0000000000..d2bc4ab829 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-keys.js @@ -0,0 +1,50 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.5.2.1 +description: > + Throws a TypeError if `this` value is not an Object. +info: | + From Map.prototype.keys() + + %MapIteratorPrototype%.next ( ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +features: + - Symbol + - Symbol.iterator +---*/ + +var map = new Map([[1, 11], [2, 22]]); +var iterator = map.keys(); + +assert.throws(TypeError, function() { + iterator.next.call(false); +}); + +assert.throws(TypeError, function() { + iterator.next.call(1); +}); + +assert.throws(TypeError, function() { + iterator.next.call(''); +}); + +assert.throws(TypeError, function() { + iterator.next.call(undefined); +}); + +assert.throws(TypeError, function() { + iterator.next.call(null); +}); + +assert.throws(TypeError, function() { + iterator.next.call(Symbol()); +}); + +// does not throw an Error +iterator.next.call(map[Symbol.iterator]()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-prototype-iterator.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-prototype-iterator.js new file mode 100644 index 0000000000..d35932d014 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-prototype-iterator.js @@ -0,0 +1,50 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.5.2.1 +description: > + Throws a TypeError if `this` value is not an Object. +info: | + Using Map.prototype[Symbol.iterator]() + + %MapIteratorPrototype%.next ( ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +features: + - Symbol + - Symbol.iterator +---*/ + +var map = new Map([[1, 11], [2, 22]]); +var iterator = map[Symbol.iterator](); + +assert.throws(TypeError, function() { + iterator.next.call(false); +}); + +assert.throws(TypeError, function() { + iterator.next.call(1); +}); + +assert.throws(TypeError, function() { + iterator.next.call(''); +}); + +assert.throws(TypeError, function() { + iterator.next.call(undefined); +}); + +assert.throws(TypeError, function() { + iterator.next.call(null); +}); + +assert.throws(TypeError, function() { + iterator.next.call(Symbol()); +}); + +// does not throw an Error +iterator.next.call(map[Symbol.iterator]()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-values.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-values.js new file mode 100644 index 0000000000..e976fc7a1b --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-values.js @@ -0,0 +1,50 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.1.5.2.1 +description: > + Throws a TypeError if `this` value is not an Object. +info: | + From Map.prototype.values() + + %MapIteratorPrototype%.next ( ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +features: + - Symbol + - Symbol.iterator +---*/ + +var map = new Map([[1, 11], [2, 22]]); +var iterator = map.values(); + +assert.throws(TypeError, function() { + iterator.next.call(false); +}); + +assert.throws(TypeError, function() { + iterator.next.call(1); +}); + +assert.throws(TypeError, function() { + iterator.next.call(''); +}); + +assert.throws(TypeError, function() { + iterator.next.call(undefined); +}); + +assert.throws(TypeError, function() { + iterator.next.call(null); +}); + +assert.throws(TypeError, function() { + iterator.next.call(Symbol()); +}); + +// does not throw an Error +iterator.next.call(map[Symbol.iterator]()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/MapIteratorPrototype/shell.js b/js/src/tests/test262/built-ins/MapIteratorPrototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/MapIteratorPrototype/shell.js |