summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Map/prototype/values
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Map/prototype/values
parentInitial commit. (diff)
downloadfirefox-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/Map/prototype/values')
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot-set.js31
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js31
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot.js40
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/length.js24
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/name.js24
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/returns-iterator-empty.js29
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/returns-iterator.js52
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/this-not-object-throw.js49
-rw-r--r--js/src/tests/test262/built-ins/Map/prototype/values/values.js24
12 files changed, 335 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/browser.js b/js/src/tests/test262/built-ins/Map/prototype/values/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/browser.js
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot-set.js b/js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot-set.js
new file mode 100644
index 0000000000..489e6b7331
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot-set.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-map.prototype.values
+description: >
+ Throws a TypeError if `this` is a Set object.
+info: |
+ Map.prototype.values ()
+
+ 1. Let M be the this value.
+ 2. Return CreateMapIterator(M, "value").
+
+ 23.1.5.1 CreateMapIterator Abstract Operation
+
+ ...
+ 2. If map does not have a [[MapData]] internal slot, throw a TypeError
+ exception.
+ ...
+features: [Set]
+---*/
+
+assert.throws(TypeError, function() {
+ Map.prototype.values.call(new Set());
+});
+
+assert.throws(TypeError, function() {
+ var m = new Map();
+ m.values.call(new Set());
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js b/js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js
new file mode 100644
index 0000000000..82f02364b6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-map.prototype.values
+description: >
+ Throws a TypeError if `this` is a WeakMap object.
+info: |
+ Map.prototype.values ()
+
+ 1. Let M be the this value.
+ 2. Return CreateMapIterator(M, "value").
+
+ 23.1.5.1 CreateMapIterator Abstract Operation
+
+ ...
+ 2. If map does not have a [[MapData]] internal slot, throw a TypeError
+ exception.
+ ...
+features: [WeakMap]
+---*/
+
+assert.throws(TypeError, function() {
+ Map.prototype.values.call(new WeakMap());
+});
+
+assert.throws(TypeError, function() {
+ var m = new Map();
+ m.values.call(new WeakMap());
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot.js b/js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot.js
new file mode 100644
index 0000000000..65ea9ca971
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/does-not-have-mapdata-internal-slot.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-map.prototype.values
+description: >
+ Throws a TypeError if `this` object does not have a [[MapData]] internal slot.
+info: |
+ Map.prototype.values ()
+
+ 1. Let M be the this value.
+ 2. Return CreateMapIterator(M, "value").
+
+ 23.1.5.1 CreateMapIterator Abstract Operation
+
+ ...
+ 2. If map does not have a [[MapData]] internal slot, throw a TypeError
+ exception.
+ ...
+
+---*/
+
+var m = new Map();
+
+assert.throws(TypeError, function() {
+ Map.prototype.values.call([]);
+});
+
+assert.throws(TypeError, function() {
+ m.values.call([]);
+});
+
+assert.throws(TypeError, function() {
+ Map.prototype.values.call({});
+});
+
+assert.throws(TypeError, function() {
+ m.values.call({});
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/length.js b/js/src/tests/test262/built-ins/Map/prototype/values/length.js
new file mode 100644
index 0000000000..304cdd7983
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/length.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-map.prototype.values
+description: >
+ Map.prototype.values.length value and descriptor.
+info: |
+ Map.prototype.values ()
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ Map.prototype.values.length, 0,
+ 'The value of `Map.prototype.values.length` is `0`'
+);
+
+verifyNotEnumerable(Map.prototype.values, 'length');
+verifyNotWritable(Map.prototype.values, 'length');
+verifyConfigurable(Map.prototype.values, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/name.js b/js/src/tests/test262/built-ins/Map/prototype/values/name.js
new file mode 100644
index 0000000000..03827d01f3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/name.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-map.prototype.values
+description: >
+ Map.prototype.values.name value and descriptor.
+info: |
+ Map.prototype.values ()
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ Map.prototype.values.name, 'values',
+ 'The value of `Map.prototype.values.name` is `"values"`'
+);
+
+verifyNotEnumerable(Map.prototype.values, 'name');
+verifyNotWritable(Map.prototype.values, 'name');
+verifyConfigurable(Map.prototype.values, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/not-a-constructor.js b/js/src/tests/test262/built-ins/Map/prototype/values/not-a-constructor.js
new file mode 100644
index 0000000000..0fd6e656d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/not-a-constructor.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ Map.prototype.values does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, Map, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Map.prototype.values), false, 'isConstructor(Map.prototype.values) must return false');
+
+assert.throws(TypeError, () => {
+ let m = new Map(); new m.values();
+}, '`let m = new Map(); new m.values()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/returns-iterator-empty.js b/js/src/tests/test262/built-ins/Map/prototype/values/returns-iterator-empty.js
new file mode 100644
index 0000000000..990723ff87
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/returns-iterator-empty.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-map.prototype.values
+description: >
+ Returns an iterator on an empty Map object.
+info: |
+ Map.prototype.values ()
+
+ ...
+ 2. Return CreateMapIterator(M, "value").
+
+ 23.1.5.1 CreateMapIterator Abstract Operation
+
+ ...
+ 7. Return iterator.
+---*/
+
+var map = new Map();
+var iterator = map.values();
+var result = iterator.next();
+
+assert.sameValue(
+ result.value, undefined,
+ 'The value of `result.value` is `undefined`'
+);
+assert.sameValue(result.done, true, 'The value of `result.done` is `true`');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/returns-iterator.js b/js/src/tests/test262/built-ins/Map/prototype/values/returns-iterator.js
new file mode 100644
index 0000000000..006b4975fc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/returns-iterator.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-map.prototype.values
+description: >
+ Returns an iterator.
+info: |
+ Map.prototype.values ( )
+
+ ...
+ 2. Return CreateMapIterator(M, "value").
+
+ 23.1.5.1 CreateMapIterator Abstract Operation
+
+ ...
+ 7. Return iterator.
+---*/
+
+var obj = {};
+var map = new Map();
+map.set(1, 'foo');
+map.set(2, obj);
+map.set(3, map);
+
+var iterator = map.values();
+var result;
+
+result = iterator.next();
+assert.sameValue(result.value, 'foo', 'First result `value` ("value")');
+assert.sameValue(result.done, false, 'First result `done` flag');
+
+result = iterator.next();
+assert.sameValue(result.value, obj, 'Second result `value` ("value")');
+assert.sameValue(result.done, false, 'Second result `done` flag');
+
+result = iterator.next();
+assert.sameValue(result.value, map, 'Third result `value` ("value")');
+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/Map/prototype/values/shell.js b/js/src/tests/test262/built-ins/Map/prototype/values/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/shell.js
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/this-not-object-throw.js b/js/src/tests/test262/built-ins/Map/prototype/values/this-not-object-throw.js
new file mode 100644
index 0000000000..372aec3a02
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/this-not-object-throw.js
@@ -0,0 +1,49 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-map.prototype.values
+description: >
+ Throws a TypeError if `this` is not an Object.
+info: |
+ Map.prototype.values ()
+
+ ...
+ 2. Return CreateMapIterator(M, "values").
+
+ 23.1.5.1 CreateMapIterator Abstract Operation
+
+ 1. If Type(map) is not Object, throw a TypeError exception.
+ ...
+features: [Symbol]
+---*/
+
+assert.throws(TypeError, function() {
+ Map.prototype.values.call(false);
+});
+
+assert.throws(TypeError, function() {
+ Map.prototype.values.call(1);
+});
+
+assert.throws(TypeError, function() {
+ Map.prototype.values.call('');
+});
+
+assert.throws(TypeError, function() {
+ Map.prototype.values.call(undefined);
+});
+
+assert.throws(TypeError, function() {
+ Map.prototype.values.call(null);
+});
+
+assert.throws(TypeError, function() {
+ Map.prototype.values.call(Symbol());
+});
+
+assert.throws(TypeError, function() {
+ var map = new Map();
+ map.values.call(false);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Map/prototype/values/values.js b/js/src/tests/test262/built-ins/Map/prototype/values/values.js
new file mode 100644
index 0000000000..3ec0c35c6f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Map/prototype/values/values.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-map.prototype.values
+description: >
+ Property type and descriptor.
+info: |
+ Map.prototype.values ()
+
+ 17 ECMAScript Standard Built-in Objects
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ typeof Map.prototype.values,
+ 'function',
+ '`typeof Map.prototype.values` is `function`'
+);
+
+verifyNotEnumerable(Map.prototype, 'values');
+verifyWritable(Map.prototype, 'values');
+verifyConfigurable(Map.prototype, 'values');
+
+reportCompare(0, 0);