diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Set/prototype/delete')
22 files changed, 468 insertions, 0 deletions
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..688b467b30 --- /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. +/*--- +esid: sec-set.prototype.delete +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..fb17ea0e00 --- /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. +/*--- +esid: sec-set.prototype.delete +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..cc84a3a368 --- /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. +/*--- +esid: sec-set.prototype.delete +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..1cea6e6103 --- /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. +/*--- +esid: sec-set.prototype.delete +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..b69fc404d7 --- /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. +/*--- +esid: sec-set.prototype.delete +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..9ac5ce0e03 --- /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. +/*--- +esid: sec-set.prototype.delete +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..0bf57e4ce0 --- /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. +/*--- +esid: sec-set.prototype.delete +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..6c564ec064 --- /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. +/*--- +esid: sec-set.prototype.delete +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..60e1ef49e3 --- /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. +/*--- +esid: sec-set.prototype.delete +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..5d28a0ad40 --- /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. +/*--- +esid: sec-set.prototype.delete +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..538d7b4370 --- /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. +/*--- +esid: sec-set.prototype.delete +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..8a8e69e886 --- /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. +/*--- +esid: sec-set.prototype.delete +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..e622e9bc17 --- /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. +/*--- +esid: sec-set.prototype.delete +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..3f40763571 --- /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. +/*--- +esid: sec-set.prototype.delete +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..11415e35c0 --- /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. +/*--- +esid: sec-set.prototype.delete +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..4dfc55488e --- /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. +/*--- +esid: sec-set.prototype.delete +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..5d97d8fb2a --- /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. +/*--- +esid: sec-set.prototype.delete +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..cf01f94cb3 --- /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. +/*--- +esid: sec-set.prototype.delete +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..ffa90305f1 --- /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. +/*--- +esid: sec-set.prototype.delete +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); |