From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../built-ins/Array/prototype/entries/browser.js | 0 .../Array/prototype/entries/iteration-mutable.js | 36 +++++++++++++++++++ .../built-ins/Array/prototype/entries/iteration.js | 41 ++++++++++++++++++++++ .../built-ins/Array/prototype/entries/length.js | 24 +++++++++++++ .../built-ins/Array/prototype/entries/name.js | 24 +++++++++++++ .../Array/prototype/entries/not-a-constructor.js | 35 ++++++++++++++++++ .../built-ins/Array/prototype/entries/prop-desc.js | 24 +++++++++++++ .../prototype/entries/return-abrupt-from-this.js | 22 ++++++++++++ .../entries/returns-iterator-from-object.js | 27 ++++++++++++++ .../Array/prototype/entries/returns-iterator.js | 32 +++++++++++++++++ .../built-ins/Array/prototype/entries/shell.js | 0 11 files changed, 265 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/browser.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/iteration-mutable.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/iteration.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/length.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/name.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/return-abrupt-from-this.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator-from-object.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator.js create mode 100644 js/src/tests/test262/built-ins/Array/prototype/entries/shell.js (limited to 'js/src/tests/test262/built-ins/Array/prototype/entries') diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/browser.js b/js/src/tests/test262/built-ins/Array/prototype/entries/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/iteration-mutable.js b/js/src/tests/test262/built-ins/Array/prototype/entries/iteration-mutable.js new file mode 100644 index 0000000000..b69fb5927a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/iteration-mutable.js @@ -0,0 +1,36 @@ +// 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-array.prototype.entries +description: > + New items in the array are accessible via iteration until iterator is "done". +info: | + The method should return a valid iterator with the context as the + IteratedObject. When an item is added to the array after the iterator is + created but before the iterator is "done" (as defined by 22.1.5.2.1) the + new item should be accessible via iteration. +---*/ + +var array = []; +var iterator = array.entries(); +var result; + +array.push('a'); + +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value[0], 0, 'First result `value` (array key)'); +assert.sameValue(result.value[1], 'a', 'First result `value (array value)'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); + +array.push('b'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag (after push)'); +assert.sameValue(result.value, undefined, 'Exhausted result `value` (after push)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/iteration.js b/js/src/tests/test262/built-ins/Array/prototype/entries/iteration.js new file mode 100644 index 0000000000..ce725c24db --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/iteration.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. +/*--- +esid: sec-array.prototype.entries +description: > + The return is a valid iterator with the array's numeric properties. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). +---*/ + +var array = ['a', 'b', 'c']; +var iterator = array.entries(); +var result; + +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value[0], 0, 'First result `value` (array key)'); +assert.sameValue(result.value[1], 'a', 'First result `value` (array value)'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); + +result = iterator.next(); +assert.sameValue(result.done, false, 'Second result `done` flag'); +assert.sameValue(result.value[0], 1, 'Second result `value` (array key)'); +assert.sameValue(result.value[1], 'b', 'Second result `value` (array value)'); +assert.sameValue(result.value.length, 2, 'Second result `value` (length)'); + +result = iterator.next(); +assert.sameValue(result.done, false, 'Third result `done` flag'); +assert.sameValue(result.value[0], 2, 'Third result `value` (array key)'); +assert.sameValue(result.value[1], 'c', 'Third result `value` (array value)'); +assert.sameValue(result.value.length, 2, 'Third result `value` (length)'); + +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/length.js b/js/src/tests/test262/built-ins/Array/prototype/entries/length.js new file mode 100644 index 0000000000..28f3093b6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/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-array.prototype.entries +description: > + Array.prototype.entries.length value and descriptor. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.entries.length, 0, + 'The value of `Array.prototype.entries.length` is `0`' +); + +verifyNotEnumerable(Array.prototype.entries, 'length'); +verifyNotWritable(Array.prototype.entries, 'length'); +verifyConfigurable(Array.prototype.entries, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/name.js b/js/src/tests/test262/built-ins/Array/prototype/entries/name.js new file mode 100644 index 0000000000..db9cd7a5d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/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-array.prototype.entries +description: > + Array.prototype.entries.name value and descriptor. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.entries.name, 'entries', + 'The value of `Array.prototype.entries.name` is `"entries"`' +); + +verifyNotEnumerable(Array.prototype.entries, 'name'); +verifyNotWritable(Array.prototype.entries, 'name'); +verifyConfigurable(Array.prototype.entries, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js new file mode 100644 index 0000000000..7629f5b507 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/not-a-constructor.js @@ -0,0 +1,35 @@ +// 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: > + Array.prototype.entries 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, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Array.prototype.entries), + false, + 'isConstructor(Array.prototype.entries) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.entries(); +}, '`new Array.prototype.entries()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/entries/prop-desc.js new file mode 100644 index 0000000000..c04251a9a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/prop-desc.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-array.prototype.entries +description: > + Property type and descriptor. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Array.prototype.entries, + 'function', + '`typeof Array.prototype.entries` is `function`' +); + +verifyNotEnumerable(Array.prototype, 'entries'); +verifyWritable(Array.prototype, 'entries'); +verifyConfigurable(Array.prototype, 'entries'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/Array/prototype/entries/return-abrupt-from-this.js new file mode 100644 index 0000000000..91a57bf125 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/return-abrupt-from-this.js @@ -0,0 +1,22 @@ +// 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-array.prototype.entries +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + Array.prototype.entries.call(undefined); +}); + +assert.throws(TypeError, function() { + Array.prototype.entries.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator-from-object.js b/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator-from-object.js new file mode 100644 index 0000000000..2a4ba60806 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator-from-object.js @@ -0,0 +1,27 @@ +// 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-array.prototype.entries +description: > + Creates an iterator from a custom object. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). +features: [Symbol.iterator] +---*/ + +var obj = { + length: 2 +}; +var iter = Array.prototype.entries.call(obj); +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].entries() is %ArrayIteratorPrototype%' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator.js b/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator.js new file mode 100644 index 0000000000..f07261270e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/entries/returns-iterator.js @@ -0,0 +1,32 @@ +// 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-array.prototype.entries +description: > + The method should return an Iterator instance. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). + + 22.1.5.1 CreateArrayIterator Abstract Operation + + ... + 2. Let iterator be ObjectCreate(%ArrayIteratorPrototype%, «‍[[IteratedObject]], + [[ArrayIteratorNextIndex]], [[ArrayIterationKind]]»). + ... + 6. Return iterator. +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +var iter = [].entries(); + +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].entries() is %ArrayIteratorPrototype%' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/entries/shell.js b/js/src/tests/test262/built-ins/Array/prototype/entries/shell.js new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3