diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Set/prototype/add')
23 files changed, 489 insertions, 0 deletions
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..159a0ef029 --- /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. +/*--- +esid: sec-set.prototype.add +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..e28138f16f --- /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. +/*--- +esid: sec-set.prototype.add +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..4049431f04 --- /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. +/*--- +esid: sec-set.prototype.add +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..b40f08509a --- /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. +/*--- +esid: sec-set.prototype.add +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..373a9c8583 --- /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. +/*--- +esid: sec-set.prototype.add +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..42c33b2a27 --- /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. +/*--- +esid: sec-set.prototype.add +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..88b79c7dae --- /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. +/*--- +esid: sec-set.prototype.add +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..f8f5441845 --- /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. +/*--- +esid: sec-set.prototype.add +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..1cef6a0cc7 --- /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. +/*--- +esid: sec-set.prototype.add +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..5635af8eb6 --- /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. +/*--- +esid: sec-set.prototype.add +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..da84ccde06 --- /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. +/*--- +esid: sec-set.prototype.add +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..f21abae912 --- /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. +/*--- +esid: sec-set.prototype.add +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..e99e6729d6 --- /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. +/*--- +esid: sec-set.prototype.add +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..d5abae701c --- /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. +/*--- +esid: sec-set.prototype.add +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..bf2e69fc91 --- /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. +/*--- +esid: sec-set.prototype.add +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..5e6996de64 --- /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. +/*--- +esid: sec-set.prototype.add +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..3d301c001f --- /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. +/*--- +esid: sec-set.prototype.add +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..5b078d29bb --- /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. +/*--- +esid: sec-set.prototype.add +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..9cc7167351 --- /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. +/*--- +esid: sec-set.prototype.add +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..28d5c75759 --- /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. +/*--- +esid: sec-set.prototype.add +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); |