diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Set/prototype/values | |
parent | Initial commit. (diff) | |
download | firefox-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/Set/prototype/values')
20 files changed, 505 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/browser.js b/js/src/tests/test262/built-ins/Set/prototype/values/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..8c09871a1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-array.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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call([]); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..ba9452f718 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,28 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(new Map()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(new Map()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..8c96537bd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,28 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call({}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..6d9fcceecb --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,28 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(Set.prototype); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(Set.prototype); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..24a79a9138 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 2. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(new WeakSet()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(new WeakSet()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/length.js b/js/src/tests/test262/built-ins/Set/prototype/values/length.js new file mode 100644 index 0000000000..8e49d1bc51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/length.js @@ -0,0 +1,19 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.values.length, 0, "The value of `Set.prototype.values.length` is `0`"); + +verifyNotEnumerable(Set.prototype.values, "length"); +verifyNotWritable(Set.prototype.values, "length"); +verifyConfigurable(Set.prototype.values, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/name.js b/js/src/tests/test262/built-ins/Set/prototype/values/name.js new file mode 100644 index 0000000000..a2458e9505 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/name.js @@ -0,0 +1,19 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.values.name, "values", "The value of `Set.prototype.values.name` is `'values'`"); + +verifyNotEnumerable(Set.prototype.values, "name"); +verifyNotWritable(Set.prototype.values, "name"); +verifyConfigurable(Set.prototype.values, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/values/not-a-constructor.js new file mode 100644 index 0000000000..f21399ca9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/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: > + Set.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, Set, arrow-function] +---*/ + +assert.sameValue(isConstructor(Set.prototype.values), false, 'isConstructor(Set.prototype.values) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.values(); +}, '`let s = new Set([]); new s.values()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator-empty.js b/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator-empty.js new file mode 100644 index 0000000000..92c4dff059 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator-empty.js @@ -0,0 +1,16 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set.prototype.values +description: > + Returns an iterator that's already done if Set is empty. +---*/ + +var set = new Set(); +var iterator = set.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/Set/prototype/values/returns-iterator.js b/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator.js new file mode 100644 index 0000000000..319cbbddbe --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/returns-iterator.js @@ -0,0 +1,43 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set.prototype.values +description: > + The method should return a valid iterator with the context as the + IteratedObject. +---*/ + +var set = new Set(); +set.add(1); +set.add(2); +set.add(3); + +var iterator = set.values(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 1, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 2, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 3, 'Third result `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/Set/prototype/values/shell.js b/js/src/tests/test262/built-ins/Set/prototype/values/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..83828a339d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-boolean.js @@ -0,0 +1,28 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(false); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(false); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-null.js new file mode 100644 index 0000000000..253f10a31d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-null.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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(null); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-number.js new file mode 100644 index 0000000000..1c8319a523 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-number.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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(0); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-string.js new file mode 100644 index 0000000000..e6e81fdba2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-string.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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(""); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(""); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..bd88d0fabf --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-symbol.js @@ -0,0 +1,28 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..14c2ec0a0e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/this-not-object-throw-undefined.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-set.prototype.values +description: > + Set.prototype.values ( ) + + ... + 2. Return CreateSetIterator(S, "value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Set.prototype.values.call(undefined); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.values.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/values/values-iteration-mutable.js b/js/src/tests/test262/built-ins/Set/prototype/values/values-iteration-mutable.js new file mode 100644 index 0000000000..c0ba8093c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/values-iteration-mutable.js @@ -0,0 +1,48 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-set.prototype.values +description: > + When an item is added to the set after the iterator is created but before + the iterator is "done" (as defined by 23.2.5.2.1), the new item should be + accessible via iteration. When an item is added to the set after the + iterator is "done", the new item should not be accessible via iteration. +---*/ + +var set = new Set(); +set.add(1); +set.add(2); + +var iterator = set.values(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 1, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +set.add(3); + +result = iterator.next(); +assert.sameValue(result.value, 2, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 3, 'Third result `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'); + +set.add(4); + +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/Set/prototype/values/values.js b/js/src/tests/test262/built-ins/Set/prototype/values/values.js new file mode 100644 index 0000000000..4a02e37d00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/values/values.js @@ -0,0 +1,23 @@ +// 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-set.prototype.values +description: > + Set.prototype.values ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.values, + "function", + "`typeof Set.prototype.values` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "values"); +verifyWritable(Set.prototype, "values"); +verifyConfigurable(Set.prototype, "values"); + +reportCompare(0, 0); |