From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../built-ins/MapIteratorPrototype/next/browser.js | 0 ...does-not-have-mapiterator-internal-slots-map.js | 41 ++++++++++++++++ .../does-not-have-mapiterator-internal-slots.js | 44 ++++++++++++++++++ .../MapIteratorPrototype/next/iteration-mutable.js | 54 ++++++++++++++++++++++ .../MapIteratorPrototype/next/iteration.js | 49 ++++++++++++++++++++ .../built-ins/MapIteratorPrototype/next/length.js | 33 +++++++++++++ .../built-ins/MapIteratorPrototype/next/name.js | 30 ++++++++++++ .../built-ins/MapIteratorPrototype/next/shell.js | 0 .../next/this-not-object-throw-entries.js | 50 ++++++++++++++++++++ .../next/this-not-object-throw-keys.js | 50 ++++++++++++++++++++ .../this-not-object-throw-prototype-iterator.js | 50 ++++++++++++++++++++ .../next/this-not-object-throw-values.js | 50 ++++++++++++++++++++ 12 files changed, 451 insertions(+) create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/browser.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots-map.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/iteration-mutable.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/iteration.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/length.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/name.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/shell.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-entries.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-keys.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-prototype-iterator.js create mode 100644 js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-values.js (limited to 'js/src/tests/test262/built-ins/MapIteratorPrototype/next') 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 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 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); -- cgit v1.2.3