summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/MapIteratorPrototype/next
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/MapIteratorPrototype/next
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/MapIteratorPrototype/next')
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots-map.js41
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/does-not-have-mapiterator-internal-slots.js44
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/iteration-mutable.js54
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/iteration.js49
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/length.js33
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/name.js30
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-entries.js50
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-keys.js50
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-prototype-iterator.js50
-rw-r--r--js/src/tests/test262/built-ins/MapIteratorPrototype/next/this-not-object-throw-values.js50
12 files changed, 451 insertions, 0 deletions
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);