diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/built-ins/Set | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Set')
227 files changed, 4913 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/browser.js b/js/src/tests/test262/built-ins/Set/Symbol.species/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/browser.js diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/length.js b/js/src/tests/test262/built-ins/Set/Symbol.species/length.js new file mode 100644 index 0000000000..06474ae5bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 23.2.2.2 +description: > + get Set [ @@species ].length is 0. +info: | + get Set [ @@species ] + + 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] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(Set, Symbol.species); + +assert.sameValue(desc.get.length, 0); + +verifyNotEnumerable(desc.get, "length"); +verifyNotWritable(desc.get, "length"); +verifyConfigurable(desc.get, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/return-value.js b/js/src/tests/test262/built-ins/Set/Symbol.species/return-value.js new file mode 100644 index 0000000000..db57da9a59 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/return-value.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-set-@@species +description: Return value of @@species accessor method +info: | + 1. Return the this value. +features: [Symbol.species] +---*/ + +var thisVal = {}; +var accessor = Object.getOwnPropertyDescriptor(Set, Symbol.species).get; + +assert.sameValue(accessor.call(thisVal), thisVal); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/shell.js b/js/src/tests/test262/built-ins/Set/Symbol.species/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/shell.js diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species-name.js b/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species-name.js new file mode 100644 index 0000000000..c9c06da821 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species-name.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. +/*--- +es6id: 23.2.2.2 +description: > + Set[Symbol.species] accessor property get name +info: | + 23.2.2.2 get Set [ @@species ] + + ... + The value of the name property of this function is "get [Symbol.species]". +features: [Symbol.species] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(Set, Symbol.species); + +assert.sameValue( + descriptor.get.name, + 'get [Symbol.species]' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species.js b/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species.js new file mode 100644 index 0000000000..f52ab2c093 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/Symbol.species/symbol-species.js @@ -0,0 +1,23 @@ +// Copyright 2015 Cubane Canada, Inc. All rights reserved. +// See LICENSE for details. + +/*--- +info: | + Set has a property at `Symbol.species` +esid: sec-get-set-@@species +author: Sam Mikes +description: Set[Symbol.species] exists per spec +includes: [propertyHelper.js] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(Set, Symbol.species); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); + +verifyNotWritable(Set, Symbol.species, Symbol.species); +verifyNotEnumerable(Set, Symbol.species); +verifyConfigurable(Set, Symbol.species); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/browser.js b/js/src/tests/test262/built-ins/Set/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/browser.js diff --git a/js/src/tests/test262/built-ins/Set/constructor.js b/js/src/tests/test262/built-ins/Set/constructor.js new file mode 100644 index 0000000000..fb34784c2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/constructor.js @@ -0,0 +1,12 @@ +// 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.2.1 +description: > + The Set constructor is the %Set% intrinsic object and the + initial value of the Set property of the global object. +---*/ + +assert.sameValue(typeof Set, "function", "`typeof Set` is `'function'`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/is-a-constructor.js b/js/src/tests/test262/built-ins/Set/is-a-constructor.js new file mode 100644 index 0000000000..d14acb2132 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/is-a-constructor.js @@ -0,0 +1,26 @@ +// 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: > + The Set constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct, Set] +---*/ + +assert.sameValue(isConstructor(Set), true, 'isConstructor(Set) must return true'); +new Set(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/length.js b/js/src/tests/test262/built-ins/Set/length.js new file mode 100644 index 0000000000..325ad0f7fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/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. +/*--- +es6id: 23.2.2 +description: > + Properties of the Set Constructor + + Besides the length property (whose value is 0) + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.length, 0, "The value of `Set.length` is `0`"); + +verifyNotEnumerable(Set, "length"); +verifyNotWritable(Set, "length"); +verifyConfigurable(Set, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/name.js b/js/src/tests/test262/built-ins/Set/name.js new file mode 100644 index 0000000000..f61b929820 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/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. +/*--- +es6id: 23.2.1.1 +description: > + Set ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.name, "Set", "The value of `Set.name` is `'Set'`"); + +verifyNotEnumerable(Set, "name"); +verifyNotWritable(Set, "name"); +verifyConfigurable(Set, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/properties-of-the-set-prototype-object.js b/js/src/tests/test262/built-ins/Set/properties-of-the-set-prototype-object.js new file mode 100644 index 0000000000..461d7ea80a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/properties-of-the-set-prototype-object.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. +/*--- +es6id: 23.2.3 +description: > + The Set prototype object is the intrinsic object %SetPrototype%. + The value of the [[Prototype]] internal slot of the Set prototype + object is the intrinsic object %ObjectPrototype% (19.1.3). The Set + prototype object is an ordinary object. It does not have a + [[SetData]] internal slot. +---*/ + +assert.sameValue( + Object.getPrototypeOf(Set.prototype), + Object.prototype, + "`Object.getPrototypeOf(Set.prototype)` returns `Object.prototype`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/Set/proto-from-ctor-realm.js new file mode 100644 index 0000000000..44dd8cee4d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/proto-from-ctor-realm.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set-iterable +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", + « [[SetData]] »). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(Set, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.Set.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype-of-set.js b/js/src/tests/test262/built-ins/Set/prototype-of-set.js new file mode 100644 index 0000000000..8e85286ed1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype-of-set.js @@ -0,0 +1,16 @@ +// 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.2.2 +description: > + The value of the [[Prototype]] internal slot of the Set constructor + is the intrinsic object %FunctionPrototype% (19.2.3). +---*/ + +assert.sameValue( + Object.getPrototypeOf(Set), + Function.prototype, + "`Object.getPrototypeOf(Set)` returns `Function.prototype`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator.js new file mode 100644 index 0000000000..55de31cca5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator.js @@ -0,0 +1,22 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Initial state of the Symbol.iterator property +info: | + The initial value of the @@iterator property is the same function object as + the initial value of the values property. + + Per ES6 section 17, the method should exist on the Set prototype, and it + should be writable and configurable, but not enumerable. +includes: [propertyHelper.js] +features: [Symbol.iterator] +es6id: 23.2.3.11 +---*/ + +assert.sameValue(Set.prototype[Symbol.iterator], Set.prototype.values); +verifyNotEnumerable(Set.prototype, Symbol.iterator); +verifyWritable(Set.prototype, Symbol.iterator); +verifyConfigurable(Set.prototype, Symbol.iterator); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/browser.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/not-a-constructor.js new file mode 100644 index 0000000000..8db788f9c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/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: > + Set.prototype[Symbol.iterator] 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, Symbol, Symbol.iterator, Set, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Set.prototype[Symbol.iterator]), + false, + 'isConstructor(Set.prototype[Symbol.iterator]) must return false' +); + +assert.throws(TypeError, () => { + let s = new Set([]); new s[Symbol.iterator](); +}, '`let s = new Set([]); new s[Symbol.iterator]()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/shell.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.iterator/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag.js new file mode 100644 index 0000000000..4b7453e215 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag.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. +/*--- +es6id: 23.2.3.12 +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + "Set". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +assert.sameValue(Set.prototype[Symbol.toStringTag], 'Set'); + +verifyNotEnumerable(Set.prototype, Symbol.toStringTag); +verifyNotWritable(Set.prototype, Symbol.toStringTag); +verifyConfigurable(Set.prototype, Symbol.toStringTag); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/browser.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/property-descriptor.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/property-descriptor.js new file mode 100644 index 0000000000..f1a3519fc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/property-descriptor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + `Object.prototype.getOwnPropertyDescriptor` should reflect the value and + writability of the @@toStringTag attribute. +includes: [propertyHelper.js] +es6id: 23.2.3.12 +features: [Symbol.toStringTag] +---*/ + +var SetProto = Object.getPrototypeOf(new Set()); + +assert.sameValue( + SetProto[Symbol.toStringTag], + 'Set', + "The value of `SetProto[Symbol.toStringTag]` is `'Set'`" +); + +verifyNotEnumerable(SetProto, Symbol.toStringTag); +verifyNotWritable(SetProto, Symbol.toStringTag); +verifyConfigurable(SetProto, Symbol.toStringTag); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/shell.js b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/Symbol.toStringTag/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/add.js b/js/src/tests/test262/built-ins/Set/prototype/add/add.js new file mode 100644 index 0000000000..c08e4b3747 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/add.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.add, + "function", + "`typeof Set.prototype.add` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "add"); +verifyWritable(Set.prototype, "add"); +verifyConfigurable(Set.prototype, "add"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/browser.js b/js/src/tests/test262/built-ins/Set/prototype/add/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..a233a6f561 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-array.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call([], 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call([], 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..f345df3fda --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-map.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(new Map(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(new Map(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..05079acb3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-object.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call({}, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call({}, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..e0700dabb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(Set.prototype, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(Set.prototype, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..a618778d61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(new WeakSet(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(new WeakSet(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/length.js b/js/src/tests/test262/built-ins/Set/prototype/add/length.js new file mode 100644 index 0000000000..fb48f68204 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.add.length, 1, "The value of `Set.prototype.add.length` is `1`"); + +verifyNotEnumerable(Set.prototype.add, "length"); +verifyNotWritable(Set.prototype.add, "length"); +verifyConfigurable(Set.prototype.add, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/name.js b/js/src/tests/test262/built-ins/Set/prototype/add/name.js new file mode 100644 index 0000000000..0d3c76fe1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.add.name, "add", "The value of `Set.prototype.add.name` is `'add'`"); + +verifyNotEnumerable(Set.prototype.add, "name"); +verifyNotWritable(Set.prototype.add, "name"); +verifyConfigurable(Set.prototype.add, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/add/not-a-constructor.js new file mode 100644 index 0000000000..c1ba69377d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/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.add 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.add), false, 'isConstructor(Set.prototype.add) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.add(); +}, '`let s = new Set([]); new s.add()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/preserves-insertion-order.js b/js/src/tests/test262/built-ins/Set/prototype/add/preserves-insertion-order.js new file mode 100644 index 0000000000..45e1504efb --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/preserves-insertion-order.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + ... + 7. Append value as the last element of entries. + ... +---*/ + +var s = new Set(); +var expects = [1, 2, 3]; + +s.add(1).add(2).add(3); + +s.forEach(function(value) { + assert.sameValue(value, expects.shift()); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/returns-this-when-ignoring-duplicate.js b/js/src/tests/test262/built-ins/Set/prototype/add/returns-this-when-ignoring-duplicate.js new file mode 100644 index 0000000000..561f3de320 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/returns-this-when-ignoring-duplicate.js @@ -0,0 +1,21 @@ +// 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.2.3.1 +description: > + Set.prototype.add ( value ) + + 1. Let S be this value. + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + ... + +---*/ + +var s = new Set([1]); + +assert.sameValue(s.add(1), s, "`s.add(1)` returns `s`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/returns-this.js b/js/src/tests/test262/built-ins/Set/prototype/add/returns-this.js new file mode 100644 index 0000000000..e329e9c978 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/returns-this.js @@ -0,0 +1,18 @@ +// 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.2.3.1 +description: > + Set.prototype.add ( value ) + + 1. Let S be this value. + ... + 8. Return S. + +---*/ + +var s = new Set(); + +assert.sameValue(s.add(1), s, "`s.add(1)` returns `s`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/shell.js b/js/src/tests/test262/built-ins/Set/prototype/add/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..4424328e19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-boolean.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(false, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(false, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-null.js new file mode 100644 index 0000000000..5ce1502da3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-null.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(null, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(null, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-number.js new file mode 100644 index 0000000000..83409429e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-number.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(0, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(0, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-string.js new file mode 100644 index 0000000000..0d1bc49f4d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-string.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call("", 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call("", 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..b65ee411de --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-symbol.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(Symbol(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..7e058f903d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/this-not-object-throw-undefined.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.add.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.add.call(undefined, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js new file mode 100644 index 0000000000..e5443abcbe --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new Set([1]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +s.add(1); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js new file mode 100644 index 0000000000..9946369ad8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new Set([-0]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +s.add(-0); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(-0)`"); + +s.add(0); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(0)`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry.js b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry.js new file mode 100644 index 0000000000..aace203963 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/add/will-not-add-duplicate-entry.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. +/*--- +es6id: 23.2.3.1 +description: > + Set.prototype.add ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new Set(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +s.add(1); +s.add(1); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(1); s.add(1);`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/browser.js b/js/src/tests/test262/built-ins/Set/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/browser.js b/js/src/tests/test262/built-ins/Set/prototype/clear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clear.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clear.js new file mode 100644 index 0000000000..2451682700 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clear.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.clear, + "function", + "`typeof Set.prototype.clear` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "clear"); +verifyWritable(Set.prototype, "clear"); +verifyConfigurable(Set.prototype, "clear"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents-from-iterable.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents-from-iterable.js new file mode 100644 index 0000000000..58cd67e1e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents-from-iterable.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new Set([1, 2, 3]); + +assert.sameValue(s.size, 3, "The value of `s.size` is `3`"); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.clear()`"); +assert.sameValue(s.has(1), false, "`s.has(1)` returns `false`"); +assert.sameValue(s.has(2), false, "`s.has(2)` returns `false`"); +assert.sameValue(s.has(3), false, "`s.has(3)` returns `false`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents.js new file mode 100644 index 0000000000..0f9c794439 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents.js @@ -0,0 +1,30 @@ +// 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.2.3.2 +description: > + Set.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new Set(); + +s.add(1).add(2).add(3); + +assert.sameValue(s.size, 3, "The value of `s.size` is `3`"); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.clear()`"); +assert.sameValue(s.has(1), false, "`s.has(1)` returns `false`"); +assert.sameValue(s.has(2), false, "`s.has(2)` returns `false`"); +assert.sameValue(s.has(3), false, "`s.has(3)` returns `false`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clears-an-empty-set.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-an-empty-set.js new file mode 100644 index 0000000000..808ae93a49 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-an-empty-set.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new Set(); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..4fa993ea90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call([]); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..d7f49ddd26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(new Map()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(new Map()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..d41d6efca9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call({}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js new file mode 100644 index 0000000000..fd77749f25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(Set.prototype); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(Set.prototype); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..2544e4188d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(new WeakSet()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(new WeakSet()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/length.js b/js/src/tests/test262/built-ins/Set/prototype/clear/length.js new file mode 100644 index 0000000000..6ccdef652d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.clear.length, 0, "The value of `Set.prototype.clear.length` is `0`"); + +verifyNotEnumerable(Set.prototype.clear, "length"); +verifyNotWritable(Set.prototype.clear, "length"); +verifyConfigurable(Set.prototype.clear, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/name.js b/js/src/tests/test262/built-ins/Set/prototype/clear/name.js new file mode 100644 index 0000000000..3e970e0450 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.clear.name, "clear", "The value of `Set.prototype.clear.name` is `'clear'`"); + +verifyNotEnumerable(Set.prototype.clear, "name"); +verifyNotWritable(Set.prototype.clear, "name"); +verifyConfigurable(Set.prototype.clear, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js new file mode 100644 index 0000000000..16f0ebd97c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/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.clear 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.clear), false, 'isConstructor(Set.prototype.clear) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.clear(); +}, '`let s = new Set([]); new s.clear()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/returns-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/clear/returns-undefined.js new file mode 100644 index 0000000000..8c9c849e0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/returns-undefined.js @@ -0,0 +1,17 @@ +// 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.2.3.2 +description: > + Set.prototype.clear ( ) + + ... + 6. Return undefined. + +---*/ + +var s = new Set(); + +assert.sameValue(s.clear(), undefined, "`s.clear()` returns `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/shell.js b/js/src/tests/test262/built-ins/Set/prototype/clear/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..3bc06aba85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-boolean.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(false); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(false); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-null.js new file mode 100644 index 0000000000..7e38151ad7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-null.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(null); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-number.js new file mode 100644 index 0000000000..4d38be7c31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-number.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(0); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-string.js new file mode 100644 index 0000000000..b30769b168 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-string.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(""); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(""); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..8ada33784a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-symbol.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..00d8b0aaf0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-undefined.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. +/*--- +es6id: 23.2.3.2 +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(undefined); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/constructor/browser.js b/js/src/tests/test262/built-ins/Set/prototype/constructor/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/constructor/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js b/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js new file mode 100644 index 0000000000..a3d086197f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js @@ -0,0 +1,18 @@ +// 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.2.3.3 +description: > + Set.prototype.constructor + + The initial value of Set.prototype.constructor is the intrinsic object %Set%. + +---*/ + +assert.sameValue( + Set.prototype.constructor, + Set, + "The value of `Set.prototype.constructor` is `Set`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor.js new file mode 100644 index 0000000000..43a75c4852 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/constructor/set-prototype-constructor.js @@ -0,0 +1,17 @@ +// 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.2.1.1 +description: > + Set ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Set.prototype, "constructor"); +verifyWritable(Set.prototype, "constructor"); +verifyConfigurable(Set.prototype, "constructor"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/constructor/shell.js b/js/src/tests/test262/built-ins/Set/prototype/constructor/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/constructor/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/browser.js b/js/src/tests/test262/built-ins/Set/prototype/delete/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-initial-iterable.js b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-initial-iterable.js new file mode 100644 index 0000000000..22358b27c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-initial-iterable.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + b. Replace the element of entries whose value is e with an element whose value is empty. + c. Return true. + ... + + +---*/ + +var s = new Set([1]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +var result = s.delete(1); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(1)`"); +assert.sameValue(result, true, "The result of `s.delete(1)` is `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-normalizes-zero.js b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-normalizes-zero.js new file mode 100644 index 0000000000..3be137ba0e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry-normalizes-zero.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + b. Replace the element of entries whose value is e with an element whose value is empty. + c. Return true. + ... + +---*/ + +var s = new Set([-0]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +var result = s.delete(+0); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(-0)`"); +assert.sameValue(result, true, "The result of `s.delete(+0)` is `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry.js b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry.js new file mode 100644 index 0000000000..69d5a0f5ad --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/delete-entry.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new Set(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +s.add(1); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(1)`"); + +var result = s.delete(1); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(1)`"); +assert.sameValue(result, true, "The result of `s.delete(1)` is `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/delete.js b/js/src/tests/test262/built-ins/Set/prototype/delete/delete.js new file mode 100644 index 0000000000..59d6223217 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/delete.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.delete, + "function", + "`typeof Set.prototype.delete` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "delete"); +verifyWritable(Set.prototype, "delete"); +verifyConfigurable(Set.prototype, "delete"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..16570d385d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call([], 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call([], 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..7968e71b97 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(new Map(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(new Map(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..ab07ec39b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call({}, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call({}, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..2cd83436d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(Set.prototype, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(Set.prototype, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..ba38153667 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(new WeakSet(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(new WeakSet(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/length.js b/js/src/tests/test262/built-ins/Set/prototype/delete/length.js new file mode 100644 index 0000000000..9b694e8cb4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.delete.length, 1, "The value of `Set.prototype.delete.length` is `1`"); + +verifyNotEnumerable(Set.prototype.delete, "length"); +verifyNotWritable(Set.prototype.delete, "length"); +verifyConfigurable(Set.prototype.delete, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/name.js b/js/src/tests/test262/built-ins/Set/prototype/delete/name.js new file mode 100644 index 0000000000..5dd8788e41 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.delete.name, "delete", "The value of `Set.prototype.delete.name` is `'delete'`"); + +verifyNotEnumerable(Set.prototype.delete, "name"); +verifyNotWritable(Set.prototype.delete, "name"); +verifyConfigurable(Set.prototype.delete, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/delete/not-a-constructor.js new file mode 100644 index 0000000000..3c978d44f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/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.delete 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.delete), false, 'isConstructor(Set.prototype.delete) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.delete(); +}, '`let s = new Set([]); new s.delete()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/returns-false-when-delete-is-noop.js b/js/src/tests/test262/built-ins/Set/prototype/delete/returns-false-when-delete-is-noop.js new file mode 100644 index 0000000000..52d7d31027 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/returns-false-when-delete-is-noop.js @@ -0,0 +1,17 @@ +// 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.2.3.4 +description: > + Set.prototype.delete ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.delete(1), false, "`s.delete(1)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js b/js/src/tests/test262/built-ins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js new file mode 100644 index 0000000000..2e5cff31f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/returns-true-when-delete-operation-occurs.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + b. Replace the element of entries whose value is e with an element whose value is empty. + c. Return true. + ... + +---*/ + +var s = new Set(); + +s.add(1); + +assert.sameValue(s.delete(1), true, "`s.delete(1)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/shell.js b/js/src/tests/test262/built-ins/Set/prototype/delete/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..c07d237b45 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-boolean.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(false, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(false, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-null.js new file mode 100644 index 0000000000..42bbf5dd35 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-null.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(null, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(null, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-number.js new file mode 100644 index 0000000000..156cf37000 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-number.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(0, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(0, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-string.js new file mode 100644 index 0000000000..a7bae769f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-string.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call("", 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call("", 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..9d04fef452 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-symbol.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(Symbol(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..59c9974644 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/delete/this-not-object-throw-undefined.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. +/*--- +es6id: 23.2.3.4 +description: > + Set.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.delete.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.delete.call(undefined, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/browser.js b/js/src/tests/test262/built-ins/Set/prototype/entries/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..9f5f20f937 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call([]); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..52df3d8a2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call(new Map()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(new Map()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..4779601fb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call({}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..65786ed6fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call(Set.prototype); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(Set.prototype); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..53f11499e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call(new WeakSet()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(new WeakSet()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/entries.js b/js/src/tests/test262/built-ins/Set/prototype/entries/entries.js new file mode 100644 index 0000000000..604eb3b364 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/entries.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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.entries, + "function", + "`typeof Set.prototype.entries` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "entries"); +verifyWritable(Set.prototype, "entries"); +verifyConfigurable(Set.prototype, "entries"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/length.js b/js/src/tests/test262/built-ins/Set/prototype/entries/length.js new file mode 100644 index 0000000000..77edd62b26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.entries.length, 0, "The value of `Set.prototype.entries.length` is `0`"); + +verifyNotEnumerable(Set.prototype.entries, "length"); +verifyNotWritable(Set.prototype.entries, "length"); +verifyConfigurable(Set.prototype.entries, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/name.js b/js/src/tests/test262/built-ins/Set/prototype/entries/name.js new file mode 100644 index 0000000000..18f62e87f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.entries.name, "entries", "The value of `Set.prototype.entries.name` is `'entries'`"); + +verifyNotEnumerable(Set.prototype.entries, "name"); +verifyNotWritable(Set.prototype.entries, "name"); +verifyConfigurable(Set.prototype.entries, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/entries/not-a-constructor.js new file mode 100644 index 0000000000..cd385a7077 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/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: > + Set.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, Set, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Set.prototype.entries), + false, + 'isConstructor(Set.prototype.entries) must return false' +); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.entries(); +}, '`let s = new Set([]); new s.entries()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator-empty.js b/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator-empty.js new file mode 100644 index 0000000000..effaedef87 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator-empty.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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 7. Return iterator. + + +---*/ + +var set = new Set(); +var iterator = set.entries(); +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/entries/returns-iterator.js b/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator.js new file mode 100644 index 0000000000..f447869a8d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/returns-iterator.js @@ -0,0 +1,58 @@ +// 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.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSetIterator Abstract Operation + + ... + 7. Return iterator. + + +---*/ + +var set = new Set(); +set.add(1); +set.add(2); +set.add(3); + +var iterator = set.entries(); +var result; + +result = iterator.next(); +assert.sameValue(result.value[0], 1, 'First result `value` ("key")'); +assert.sameValue(result.value[1], 1, 'First result `value` ("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` ("key")'); +assert.sameValue(result.value[1], 2, 'Second result `value` ("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` ("key")'); +assert.sameValue(result.value[1], 3, 'Third result `value` ("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/Set/prototype/entries/shell.js b/js/src/tests/test262/built-ins/Set/prototype/entries/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..da9654b0d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call(false); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(false); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-null.js new file mode 100644 index 0000000000..635f15f890 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call(null); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-number.js new file mode 100644 index 0000000000..05424ec176 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call(0); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-string.js new file mode 100644 index 0000000000..9ec8e0f0c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call(""); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(""); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..fa92de9f1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/entries/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..2fc641b575 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/entries/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. +/*--- +es6id: 23.2.3.5 +description: > + Set.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(S, "key+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.entries.call(undefined); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.entries.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/browser.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-boolean.js new file mode 100644 index 0000000000..0c77c6c132 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-boolean.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `false` as callback + +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(false); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-null.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-null.js new file mode 100644 index 0000000000..3b7bac8cc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-null.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `null` as callback + +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-number.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-number.js new file mode 100644 index 0000000000..999dbbefb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-number.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `number` as callback + +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-string.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-string.js new file mode 100644 index 0000000000..db68ff5d77 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-string.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `string` as callback + +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(""); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-symbol.js new file mode 100644 index 0000000000..21deec14ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-symbol.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `symbol` as callback + +features: [Symbol] +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-undefined.js new file mode 100644 index 0000000000..2c91f31b26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/callback-not-callable-undefined.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `undefined` as callback + +---*/ + +var s = new Set([1]); + +assert.throws(TypeError, function() { + s.forEach(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..7b3bedd148 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call([], function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call([], function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..f4e72b5284 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(new Map(), function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(new Map(), function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..3147d7d687 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call({}, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call({}, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..da80ca5c2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(Set.prototype, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(Set.prototype, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..e4d452f2de --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(new WeakSet(), function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(new WeakSet(), function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/forEach.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/forEach.js new file mode 100644 index 0000000000..2e3f31513a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/forEach.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.forEach, + "function", + "`typeof Set.prototype.forEach` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "forEach"); +verifyWritable(Set.prototype, "forEach"); +verifyConfigurable(Set.prototype, "forEach"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-insertion-order.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-insertion-order.js new file mode 100644 index 0000000000..2650e3cb31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-insertion-order.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var s = new Set(); +var expects = [1, 2, 3]; + +s.add(1).add(2).add(3); + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-iterable-entry-order.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-iterable-entry-order.js new file mode 100644 index 0000000000..655aa550f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-in-iterable-entry-order.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var expects = [1, 2, 3]; +var s = new Set(expects); + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js new file mode 100644 index 0000000000..5b931a4038 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.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.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + ... + New values added after the call to forEach begins are visited. + +---*/ + + +var s = new Set([1]); +var expects = [1, 2, 3]; + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + if (value === 1) { + set.add(2); + } + + if (value === 2) { + set.add(3); + } + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-deleted-then-readded.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-deleted-then-readded.js new file mode 100644 index 0000000000..29142104f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-deleted-then-readded.js @@ -0,0 +1,47 @@ +// 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.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + ... + Values that are deleted after the call to forEach begins and before being visited are not visited unless the value is added again before the forEach call completes. + ... + +---*/ + + +var s = new Set([1, 2, 3]); +var expects = [1, 3, 2]; + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + // Delete `2` before being visited + if (value === 1) { + set.delete(2); + } + + // Re-add `2` before forEach call completes + if (value === 3) { + set.add(2); + } + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-not-deleted.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-not-deleted.js new file mode 100644 index 0000000000..54f21f8c34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-not-deleted.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + callbackfn should be a function that accepts three arguments. forEach calls callbackfn once for each value present in the set object, in value insertion order. callbackfn is called only for values of the Set which actually exist; it is not called for keys that have been deleted from the set. + +---*/ + +var expects = [1, 3]; +var s = new Set([1, 2, 3]); + +s.delete(2); + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js new file mode 100644 index 0000000000..c55a11a3c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js @@ -0,0 +1,47 @@ +// 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.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + ... + a value will be revisited if it is deleted after it has been visited and then re-added before the forEach call completes. + ... + +---*/ + + +var s = new Set([1, 2, 3]); +var expects = [1, 2, 3, 1]; + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + // Delete `1` after visit + if (value === 2) { + set.delete(1); + } + + // Re-add `1` + if (value === 3) { + set.add(1); + } + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/length.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/length.js new file mode 100644 index 0000000000..d4f6549441 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + The length property of the forEach method is 1. + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.forEach.length, 1, "The value of `Set.prototype.forEach.length` is `1`"); + +verifyNotEnumerable(Set.prototype.forEach, "length"); +verifyNotWritable(Set.prototype.forEach, "length"); +verifyConfigurable(Set.prototype.forEach, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/name.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/name.js new file mode 100644 index 0000000000..c27b5064ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.forEach.name, "forEach", "The value of `Set.prototype.forEach.name` is `'forEach'`"); + +verifyNotEnumerable(Set.prototype.forEach, "name"); +verifyNotWritable(Set.prototype.forEach, "name"); +verifyConfigurable(Set.prototype.forEach, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/not-a-constructor.js new file mode 100644 index 0000000000..96509bf80a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/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: > + Set.prototype.forEach 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.forEach), + false, + 'isConstructor(Set.prototype.forEach) must return false' +); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.forEach(() => {}); +}, '`let s = new Set([]); new s.forEach(() => {})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/returns-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/returns-undefined.js new file mode 100644 index 0000000000..bffa40ec39 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/returns-undefined.js @@ -0,0 +1,21 @@ +// 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.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 8. Return undefined. + +---*/ + +var s = new Set([1]); + +assert.sameValue( + s.forEach(function() {}), + undefined, + "`s.forEach(function() {})` returns `undefined`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/shell.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.js new file mode 100644 index 0000000000..6c0aace0aa --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + + An arrow function will ignore an explicit thisArg + +features: [arrow-function] +---*/ + +var s = new Set([1]); +var usurper = {}; +var counter = 0; + +s.forEach(_ => { + assert.notSameValue(this, usurper, "`this` is not `usurper`"); + counter++; +}, usurper); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit.js new file mode 100644 index 0000000000..c4c2e00626 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-arg-explicit.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... +---*/ + +var s = new Set([1]); +var thisArg = {}; +var counter = 0; + +s.forEach(function() { + assert.sameValue(this, thisArg, "`this` is `thisArg`"); + counter++; +}, thisArg); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-non-strict.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-non-strict.js new file mode 100644 index 0000000000..f4627dc639 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-non-strict.js @@ -0,0 +1,26 @@ +// 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.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + +flags: [noStrict] +---*/ + +var s = new Set([1]); +var counter = 0; +var globalObject = this; + +s.forEach(function() { + assert.sameValue(this, globalObject, "`this` is the global object in non-strict mode code"); + counter++; +}); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..ff928e1c34 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-boolean.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(false, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(false, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-null.js new file mode 100644 index 0000000000..6c2cfda6b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-null.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(null, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(null, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-number.js new file mode 100644 index 0000000000..20ecdc89dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-number.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(0, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(0, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-string.js new file mode 100644 index 0000000000..5f48fc3405 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-string.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call("", function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call("", function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..52a3be80d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-symbol.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(Symbol(), function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(Symbol(), function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..c4433cd528 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-not-object-throw-undefined.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.forEach.call(undefined, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.forEach.call(undefined, function() {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/this-strict-strict.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-strict-strict.js new file mode 100644 index 0000000000..873a70b7a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/this-strict-strict.js @@ -0,0 +1,26 @@ +'use strict'; +// 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.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + +flags: [onlyStrict] +---*/ + +var s = new Set([1]); +var counter = 0; + +s.forEach(function() { + assert.sameValue(this, undefined, "`this` is `undefined` in strict mode code"); + counter++; +}); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/forEach/throws-when-callback-throws.js b/js/src/tests/test262/built-ins/Set/prototype/forEach/throws-when-callback-throws.js new file mode 100644 index 0000000000..885aa63596 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/forEach/throws-when-callback-throws.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. +/*--- +es6id: 23.2.3.6 +description: > + Set.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var s = new Set([1]); +var counter = 0; + +assert.throws(Error, function() { + s.forEach(function() { + counter++; + throw new Error(); + }); +}); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/browser.js b/js/src/tests/test262/built-ins/Set/prototype/has/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..ea7976fea4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-array.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call([], 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call([], 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..319f6bb8b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-map.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(new Map(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(new Map(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..155680afdf --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-object.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call({}, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call({}, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 0000000000..4088d43ec6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(Set.prototype, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(Set.prototype, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..cdb2d2c451 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(new WeakSet(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(new WeakSet(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/has.js b/js/src/tests/test262/built-ins/Set/prototype/has/has.js new file mode 100644 index 0000000000..e0e9128486 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/has.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.has, + "function", + "`typeof Set.prototype.has` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "has"); +verifyWritable(Set.prototype, "has"); +verifyConfigurable(Set.prototype, "has"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/length.js b/js/src/tests/test262/built-ins/Set/prototype/has/length.js new file mode 100644 index 0000000000..993947b2ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.has.length, 1, "The value of `Set.prototype.has.length` is `1`"); + +verifyNotEnumerable(Set.prototype.has, "length"); +verifyNotWritable(Set.prototype.has, "length"); +verifyConfigurable(Set.prototype.has, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/name.js b/js/src/tests/test262/built-ins/Set/prototype/has/name.js new file mode 100644 index 0000000000..27e854db3d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.has.name, "has", "The value of `Set.prototype.has.name` is `'has'`"); + +verifyNotEnumerable(Set.prototype.has, "name"); +verifyNotWritable(Set.prototype.has, "name"); +verifyConfigurable(Set.prototype.has, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/has/not-a-constructor.js new file mode 100644 index 0000000000..8f41ff0c1f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/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.has 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.has), false, 'isConstructor(Set.prototype.has) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.has(); +}, '`let s = new Set([]); new s.has()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.js new file mode 100644 index 0000000000..b47906774e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +s.add(undefined); +assert.sameValue(s.has(undefined), true, "`s.has(undefined)` returns `true`"); + +var result = s.delete(undefined); + +assert.sameValue(s.has(undefined), false, "`s.has(undefined)` returns `false`"); +assert.sameValue(result, true, "The result of `s.delete(undefined)` is `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-boolean.js new file mode 100644 index 0000000000..5c66d3699b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-boolean.js @@ -0,0 +1,17 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(false), false, "`s.has(false)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-nan.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-nan.js new file mode 100644 index 0000000000..04d9233459 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-nan.js @@ -0,0 +1,17 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(NaN), false, "`s.has(NaN)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-null.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-null.js new file mode 100644 index 0000000000..3249bcf876 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-null.js @@ -0,0 +1,17 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(null), false, "`s.has(null)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-number.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-number.js new file mode 100644 index 0000000000..304becb6ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-number.js @@ -0,0 +1,17 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(0), false, "`s.has(0)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-string.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-string.js new file mode 100644 index 0000000000..b2e04b1c98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-string.js @@ -0,0 +1,17 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(""), false, "`s.has('')` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-symbol.js new file mode 100644 index 0000000000..aa971561fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-symbol.js @@ -0,0 +1,18 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +features: [Symbol] +---*/ + +var s = new Set(); + +assert.sameValue(s.has(Symbol()), false, "`s.has(Symbol())` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-undefined.js new file mode 100644 index 0000000000..3cef798233 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-false-when-value-not-present-undefined.js @@ -0,0 +1,17 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new Set(); + +assert.sameValue(s.has(undefined), false, "`s.has(undefined)` returns `false`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-boolean.js new file mode 100644 index 0000000000..dd197d1972 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-boolean.js @@ -0,0 +1,21 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add(false) + +assert.sameValue(s.has(false), true, "`s.has(false)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-nan.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-nan.js new file mode 100644 index 0000000000..5e016620e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-nan.js @@ -0,0 +1,21 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add(NaN) + +assert.sameValue(s.has(NaN), true, "`s.has(NaN)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-null.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-null.js new file mode 100644 index 0000000000..1b54877cd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-null.js @@ -0,0 +1,21 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add(null) + +assert.sameValue(s.has(null), true, "`s.has(null)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-number.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-number.js new file mode 100644 index 0000000000..b5fa8735e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-number.js @@ -0,0 +1,21 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add(0) + +assert.sameValue(s.has(0), true, "`s.has(0)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-string.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-string.js new file mode 100644 index 0000000000..de466241a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-string.js @@ -0,0 +1,21 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add("") + +assert.sameValue(s.has(""), true, "`s.has('')` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-symbol.js new file mode 100644 index 0000000000..74787833ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-symbol.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +features: [Symbol] +---*/ + +var s = new Set(); +var a = Symbol(); + +s.add(a) + +assert.sameValue(s.has(a), true, "`s.has(a)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-undefined.js new file mode 100644 index 0000000000..fa02a98986 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/returns-true-when-value-present-undefined.js @@ -0,0 +1,21 @@ +// 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.2.3.7 +description: > + Set.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new Set(); + +s.add(undefined) + +assert.sameValue(s.has(undefined), true, "`s.has(undefined)` returns `true`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/shell.js b/js/src/tests/test262/built-ins/Set/prototype/has/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..2260eebffa --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-boolean.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(false, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(false, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-null.js new file mode 100644 index 0000000000..e7b5fdcd89 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-null.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(null, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(null, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-number.js new file mode 100644 index 0000000000..2fb8083dc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-number.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(0, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(0, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-string.js new file mode 100644 index 0000000000..7ffca592ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-string.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call("", 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call("", 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..b7623d956b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-symbol.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(Symbol(), 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..8c6276c34f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/has/this-not-object-throw-undefined.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. +/*--- +es6id: 23.2.3.7 +description: > + Set.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.has.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.has.call(undefined, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/keys/browser.js b/js/src/tests/test262/built-ins/Set/prototype/keys/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/keys/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/keys/keys.js b/js/src/tests/test262/built-ins/Set/prototype/keys/keys.js new file mode 100644 index 0000000000..a674b3de3e --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/keys/keys.js @@ -0,0 +1,17 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- + description: > + The initial value of the keys property is the same function object as the + initial value of the values property. + es6id: 23.2.3.8 +---*/ + +assert.sameValue( + Set.prototype.keys, + Set.prototype.values, + "The value of `Set.prototype.keys` is `Set.prototype.values`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/keys/shell.js b/js/src/tests/test262/built-ins/Set/prototype/keys/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/keys/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/set-prototype.js b/js/src/tests/test262/built-ins/Set/prototype/set-prototype.js new file mode 100644 index 0000000000..66b5a2f0a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/set-prototype.js @@ -0,0 +1,17 @@ +// 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.2.1.1 +description: > + Set ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "Set"); +verifyWritable(this, "Set"); +verifyConfigurable(this, "Set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/shell.js b/js/src/tests/test262/built-ins/Set/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/browser.js b/js/src/tests/test262/built-ins/Set/prototype/size/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/length.js b/js/src/tests/test262/built-ins/Set/prototype/size/length.js new file mode 100644 index 0000000000..9ba1b86f78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/length.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. +/*--- +es6id: 23.2.3.9 +description: > + get Set.prototype.size + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(Set.prototype, "size"); + + +assert.sameValue(descriptor.get.length, 0, "The value of `Set.prototype.size.length` is `0`"); + +verifyNotEnumerable(descriptor.get, "length"); +verifyNotWritable(descriptor.get, "length"); +verifyConfigurable(descriptor.get, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/name.js b/js/src/tests/test262/built-ins/Set/prototype/size/name.js new file mode 100644 index 0000000000..d8d974941c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/name.js @@ -0,0 +1,25 @@ +// 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.2.3.9 +description: > + get Set.prototype.size + + 17 ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(Set.prototype, "size"); + + +assert.sameValue(descriptor.get.name, "get size", "The value of `descriptor.get.name` is `'get size'`"); + +verifyNotEnumerable(descriptor.get, "name"); +verifyNotWritable(descriptor.get, "name"); +verifyConfigurable(descriptor.get, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.js b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.js new file mode 100644 index 0000000000..40430b095f --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.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. +/*--- +es6id: 23.2.3.9 +description: > + get Set.prototype.size + + 5. Let count be 0. + 6. For each e that is an element of entries + a. If e is not empty, set count to count+1. + + Before and after add(), delete() +---*/ + +var s = new Set(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +s.add(0); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(0)`"); + +s.delete(0); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(0)`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-insertion.js b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-insertion.js new file mode 100644 index 0000000000..c264a5c1dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-insertion.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. +/*--- +es6id: 23.2.3.9 +description: > + get Set.prototype.size + + 5. Let count be 0. + 6. For each e that is an element of entries + a. If e is not empty, set count to count+1. + +features: [Symbol] +---*/ + +var s = new Set(); + +s.add(0); +s.add(undefined); +s.add(false); +s.add(NaN); +s.add(null); +s.add(""); +s.add(Symbol()); + +assert.sameValue(s.size, 7, "The value of `s.size` is `7`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-iterable.js b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-iterable.js new file mode 100644 index 0000000000..e97fa31235 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/returns-count-of-present-values-by-iterable.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. +/*--- +es6id: 23.2.3.9 +description: > + get Set.prototype.size + + 5. Let count be 0. + 6. For each e that is an element of entries + a. If e is not empty, set count to count+1. + +features: [Symbol] +---*/ + +var s = new Set([0, undefined, false, NaN, null, "", Symbol()]); + +assert.sameValue(s.size, 7, "The value of `s.size` is `7`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/shell.js b/js/src/tests/test262/built-ins/Set/prototype/size/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/size/size.js b/js/src/tests/test262/built-ins/Set/prototype/size/size.js new file mode 100644 index 0000000000..ff64bb2a09 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/size/size.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. +/*--- +es6id: 23.2.3.9 +description: > + get Set.prototype.size + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(Set.prototype, "size"); + +assert.sameValue( + typeof descriptor.get, + "function", + "`typeof descriptor.get` is `'function'`" +); +assert.sameValue( + typeof descriptor.set, + "undefined", + "`typeof descriptor.set` is `\"undefined\"`" +); + +verifyNotEnumerable(Set.prototype, "size"); +verifyConfigurable(Set.prototype, "size"); + +reportCompare(0, 0); 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..2cedb8d587 --- /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. +/*--- +es6id: 23.2.3.10 +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..e399cfcbf8 --- /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. +/*--- +es6id: 23.2.3.10 +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..a56b2754a0 --- /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. +/*--- +es6id: 23.2.3.10 +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..4e16133e02 --- /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. +/*--- +es6id: 23.2.3.10 +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..30f013e9c8 --- /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. +/*--- +es6id: 23.2.3.10 +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..13c6cc1974 --- /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. +/*--- +es6id: 23.2.3.10 +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..d3ffda7b7e --- /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. +/*--- +es6id: 23.2.3.10 +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..e94de1e909 --- /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. + +/*--- + description: > + Returns an iterator that's already done if Set is empty. + es6id: 23.2.3.10 +---*/ + +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..f70d95efd8 --- /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. + +/*--- + description: > + The method should return a valid iterator with the context as the + IteratedObject. + es6id: 23.2.3.10 +---*/ + +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..56836529e8 --- /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. +/*--- +es6id: 23.2.3.10 +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..7876bbb481 --- /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. +/*--- +es6id: 23.2.3.10 +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..125e8c8124 --- /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. +/*--- +es6id: 23.2.3.10 +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..d2394a65eb --- /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. +/*--- +es6id: 23.2.3.10 +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..a251098894 --- /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. +/*--- +es6id: 23.2.3.10 +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..9d3be925b1 --- /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. +/*--- +es6id: 23.2.3.10 +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..cc943f0a3b --- /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. + +/*--- + 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. + es6id: 23.2.3.10 +---*/ + +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..08068a23e2 --- /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. +/*--- +es6id: 23.2.3.10 +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); diff --git a/js/src/tests/test262/built-ins/Set/set-does-not-throw-when-add-is-not-callable.js b/js/src/tests/test262/built-ins/Set/set-does-not-throw-when-add-is-not-callable.js new file mode 100644 index 0000000000..6ef5492164 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-does-not-throw-when-add-is-not-callable.js @@ -0,0 +1,35 @@ +// 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.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +Set.prototype.add = null; + +var s = new Set(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-get-add-method-failure.js b/js/src/tests/test262/built-ins/Set/set-get-add-method-failure.js new file mode 100644 index 0000000000..e097904635 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-get-add-method-failure.js @@ -0,0 +1,30 @@ +// 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.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 6. If iterable is either undefined or null, let iter be undefined. + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). +---*/ + +function MyError() {} +Object.defineProperty(Set.prototype, 'add', { + get: function() { + throw new MyError(); + } +}); + +new Set(); + +assert.throws(MyError, function() { + new Set([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterable-calls-add.js b/js/src/tests/test262/built-ins/Set/set-iterable-calls-add.js new file mode 100644 index 0000000000..e133478832 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterable-calls-add.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.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +var setAdd = Set.prototype.add; +var counter = 0; + +Set.prototype.add = function(value) { + counter++; + setAdd.call(this, value); +}; + +var s = new Set([1, 2]); + +assert.sameValue(counter, 2, "`Set.prototype.add` called twice."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterable-empty-does-not-call-add.js b/js/src/tests/test262/built-ins/Set/set-iterable-empty-does-not-call-add.js new file mode 100644 index 0000000000..e928b36839 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterable-empty-does-not-call-add.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.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +var setAdd = Set.prototype.add; +var counter = 0; + +Set.prototype.add = function(value) { + counter++; + setAdd.call(this, value); +}; + +var s = new Set([]); + +assert.sameValue(counter, 0, "`Set.prototype.add` was not called."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterable-throws-when-add-is-not-callable.js b/js/src/tests/test262/built-ins/Set/set-iterable-throws-when-add-is-not-callable.js new file mode 100644 index 0000000000..e327969137 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterable-throws-when-add-is-not-callable.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. +/*--- +es6id: 23.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + + +Set.prototype.add = null; + +assert.throws(TypeError, function() { + new Set([1, 2]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterable.js b/js/src/tests/test262/built-ins/Set/set-iterable.js new file mode 100644 index 0000000000..8f7eef779c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterable.js @@ -0,0 +1,33 @@ +// 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.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +var s = new Set([1, 2]); + +assert.sameValue(s.size, 2, "The value of `s.size` is `2`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterator-close-after-add-failure.js b/js/src/tests/test262/built-ins/Set/set-iterator-close-after-add-failure.js new file mode 100644 index 0000000000..4ec88ecb78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterator-close-after-add-failure.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.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +features: [Symbol.iterator] +---*/ + +var count = 0; +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + value: null, + done: false + }; + }, + return: function() { + count += 1; + } + }; +}; +Set.prototype.add = function() { + throw new Error(); +} + +assert.throws(Error, function() { + new Set(iterable); +}); + +assert.sameValue( + count, 1, "The iterator is closed when `Set.prototype.add` throws an error." +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterator-next-failure.js b/js/src/tests/test262/built-ins/Set/set-iterator-next-failure.js new file mode 100644 index 0000000000..d5a4eb3c65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterator-next-failure.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. +/*--- +es6id: 23.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). +features: [Symbol.iterator] +---*/ + +var iterable = {}; + +function MyError() {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + throw new MyError(); + } + }; +}; + +assert.throws(MyError, function() { + new Set(iterable); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-iterator-value-failure.js b/js/src/tests/test262/built-ins/Set/set-iterator-value-failure.js new file mode 100644 index 0000000000..5ad4ffff82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-iterator-value-failure.js @@ -0,0 +1,39 @@ +// 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.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 9. Repeat + ... + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). +features: [Symbol.iterator] +---*/ + +var count = 0; +var iterable = {}; + +function MyError() {} +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + get value() { + throw new MyError(); + }, + done: false + }; + } + }; +}; + +assert.throws(MyError, function() { + new Set(iterable); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-newtarget.js b/js/src/tests/test262/built-ins/Set/set-newtarget.js new file mode 100644 index 0000000000..8ef18f0fab --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-newtarget.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. +/*--- +es6id: 23.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 2. Let set be OrdinaryCreateFromConstructor(NewTarget, "%SetPrototype%", «[[SetData]]» ). + ... + +---*/ + +var s1 = new Set(); + +assert.sameValue( + Object.getPrototypeOf(s1), + Set.prototype, + "`Object.getPrototypeOf(s1)` returns `Set.prototype`" +); + +var s2 = new Set([1, 2]); + +assert.sameValue( + Object.getPrototypeOf(s2), + Set.prototype, + "`Object.getPrototypeOf(s2)` returns `Set.prototype`" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-no-iterable.js b/js/src/tests/test262/built-ins/Set/set-no-iterable.js new file mode 100644 index 0000000000..9dd7698822 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-no-iterable.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. +/*--- +es6id: 23.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 5. If iterable is not present, let iterable be undefined. + 6. If iterable is either undefined or null, let iter be undefined. + ... + 8. If iter is undefined, return set. + +---*/ + + +assert.sameValue(new Set().size, 0, "The value of `new Set().size` is `0`"); +assert.sameValue(new Set(undefined).size, 0, "The value of `new Set(undefined).size` is `0`"); +assert.sameValue(new Set(null).size, 0, "The value of `new Set(null).size` is `0`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set-undefined-newtarget.js b/js/src/tests/test262/built-ins/Set/set-undefined-newtarget.js new file mode 100644 index 0000000000..d905d0743d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set-undefined-newtarget.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. +/*--- +es6id: 23.2.1.1 +description: > + Set ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + 1. If NewTarget is undefined, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set(); +}); + +assert.throws(TypeError, function() { + Set([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/set.js b/js/src/tests/test262/built-ins/Set/set.js new file mode 100644 index 0000000000..66b5a2f0a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/set.js @@ -0,0 +1,17 @@ +// 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.2.1.1 +description: > + Set ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "Set"); +verifyWritable(this, "Set"); +verifyConfigurable(this, "Set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/shell.js b/js/src/tests/test262/built-ins/Set/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/shell.js @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/Set/symbol-as-entry.js b/js/src/tests/test262/built-ins/Set/symbol-as-entry.js new file mode 100644 index 0000000000..6981566146 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/symbol-as-entry.js @@ -0,0 +1,19 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.4 +description: > + Symbol as Set entry +features: [Symbol, Set] +---*/ +var set = new Set(); +var sym = Symbol(); + +set.add(sym); + +assert.sameValue(set.size, 1, "The value of `set.size` is `1`, after executing `set.add(sym)`"); +assert.sameValue(set.has(sym), true, "`set.has(sym)` returns `true`"); +assert.sameValue(set.delete(sym), true, "`set.delete(sym)` returns `true`"); +assert.sameValue(set.size, 0, "The value of `set.size` is `0`"); + +reportCompare(0, 0); |