From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../built-ins/WeakSet/add-not-callable-throws.js | 27 +++++++++++++ js/src/tests/test262/built-ins/WeakSet/browser.js | 0 .../tests/test262/built-ins/WeakSet/constructor.js | 15 ++++++++ .../test262/built-ins/WeakSet/empty-iterable.js | 33 ++++++++++++++++ .../built-ins/WeakSet/get-add-method-failure.js | 32 +++++++++++++++ .../test262/built-ins/WeakSet/is-a-constructor.js | 26 +++++++++++++ .../test262/built-ins/WeakSet/iterable-failure.js | 21 ++++++++++ .../WeakSet/iterable-with-object-values.js | 31 +++++++++++++++ .../WeakSet/iterable-with-symbol-values.js | 37 ++++++++++++++++++ .../WeakSet/iterator-close-after-add-failure.js | 45 ++++++++++++++++++++++ .../built-ins/WeakSet/iterator-next-failure.js | 31 +++++++++++++++ .../built-ins/WeakSet/iterator-value-failure.js | 37 ++++++++++++++++++ js/src/tests/test262/built-ins/WeakSet/length.js | 16 ++++++++ js/src/tests/test262/built-ins/WeakSet/name.js | 22 +++++++++++ .../tests/test262/built-ins/WeakSet/no-iterable.js | 26 +++++++++++++ .../properties-of-the-weakset-prototype-object.js | 23 +++++++++++ .../built-ins/WeakSet/proto-from-ctor-realm.js | 31 +++++++++++++++ .../built-ins/WeakSet/prototype-of-weakset.js | 16 ++++++++ .../WeakSet/prototype/Symbol.toStringTag.js | 23 +++++++++++ .../test262/built-ins/WeakSet/prototype/add/add.js | 24 ++++++++++++ .../WeakSet/prototype/add/adds-object-element.js | 26 +++++++++++++ .../WeakSet/prototype/add/adds-symbol-element.js | 27 +++++++++++++ .../built-ins/WeakSet/prototype/add/browser.js | 0 ...oes-not-have-weaksetdata-internal-slot-array.js | 26 +++++++++++++ .../does-not-have-weaksetdata-internal-slot-map.js | 26 +++++++++++++ ...es-not-have-weaksetdata-internal-slot-object.js | 26 +++++++++++++ .../does-not-have-weaksetdata-internal-slot-set.js | 26 +++++++++++++ ...-weaksetdata-internal-slot-weakset-prototype.js | 26 +++++++++++++ .../built-ins/WeakSet/prototype/add/length.js | 23 +++++++++++ .../built-ins/WeakSet/prototype/add/name.js | 23 +++++++++++ .../WeakSet/prototype/add/not-a-constructor.js | 35 +++++++++++++++++ .../WeakSet/prototype/add/returns-this-symbol.js | 21 ++++++++++ .../returns-this-when-ignoring-duplicate-symbol.js | 25 ++++++++++++ .../add/returns-this-when-ignoring-duplicate.js | 22 +++++++++++ .../WeakSet/prototype/add/returns-this.js | 19 +++++++++ .../built-ins/WeakSet/prototype/add/shell.js | 0 .../prototype/add/this-not-object-throw-boolean.js | 23 +++++++++++ .../prototype/add/this-not-object-throw-null.js | 23 +++++++++++ .../prototype/add/this-not-object-throw-number.js | 23 +++++++++++ .../prototype/add/this-not-object-throw-string.js | 23 +++++++++++ .../prototype/add/this-not-object-throw-symbol.js | 23 +++++++++++ .../add/this-not-object-throw-undefined.js | 23 +++++++++++ .../add/throw-when-value-cannot-be-held-weakly.js | 38 ++++++++++++++++++ .../test262/built-ins/WeakSet/prototype/browser.js | 0 .../WeakSet/prototype/constructor/browser.js | 0 .../WeakSet/prototype/constructor/shell.js | 0 .../weakset-prototype-constructor-intrinsic.js | 16 ++++++++ .../constructor/weakset-prototype-constructor.js | 19 +++++++++ .../built-ins/WeakSet/prototype/delete/browser.js | 0 .../delete/delete-entry-initial-iterable.js | 29 ++++++++++++++ .../prototype/delete/delete-object-entry.js | 28 ++++++++++++++ .../prototype/delete/delete-symbol-entry.js | 34 ++++++++++++++++ .../built-ins/WeakSet/prototype/delete/delete.js | 25 ++++++++++++ ...oes-not-have-weaksetdata-internal-slot-array.js | 25 ++++++++++++ .../does-not-have-weaksetdata-internal-slot-map.js | 25 ++++++++++++ ...es-not-have-weaksetdata-internal-slot-object.js | 25 ++++++++++++ .../does-not-have-weaksetdata-internal-slot-set.js | 26 +++++++++++++ ...-weaksetdata-internal-slot-weakset-prototype.js | 25 ++++++++++++ .../built-ins/WeakSet/prototype/delete/length.js | 24 ++++++++++++ .../built-ins/WeakSet/prototype/delete/name.js | 24 ++++++++++++ .../WeakSet/prototype/delete/not-a-constructor.js | 35 +++++++++++++++++ .../delete/returns-false-when-delete-is-noop.js | 19 +++++++++ ...turns-false-when-value-cannot-be-held-weakly.js | 22 +++++++++++ .../built-ins/WeakSet/prototype/delete/shell.js | 0 .../delete/this-not-object-throw-boolean.js | 22 +++++++++++ .../prototype/delete/this-not-object-throw-null.js | 22 +++++++++++ .../delete/this-not-object-throw-number.js | 22 +++++++++++ .../delete/this-not-object-throw-string.js | 22 +++++++++++ .../delete/this-not-object-throw-symbol.js | 23 +++++++++++ .../delete/this-not-object-throw-undefined.js | 22 +++++++++++ .../built-ins/WeakSet/prototype/has/browser.js | 0 ...oes-not-have-weaksetdata-internal-slot-array.js | 25 ++++++++++++ .../does-not-have-weaksetdata-internal-slot-map.js | 25 ++++++++++++ ...es-not-have-weaksetdata-internal-slot-object.js | 25 ++++++++++++ .../does-not-have-weaksetdata-internal-slot-set.js | 26 +++++++++++++ ...-weaksetdata-internal-slot-weakset-prototype.js | 25 ++++++++++++ .../test262/built-ins/WeakSet/prototype/has/has.js | 25 ++++++++++++ .../built-ins/WeakSet/prototype/has/length.js | 24 ++++++++++++ .../built-ins/WeakSet/prototype/has/name.js | 24 ++++++++++++ .../WeakSet/prototype/has/not-a-constructor.js | 35 +++++++++++++++++ .../returns-false-when-object-value-not-present.js | 25 ++++++++++++ .../returns-false-when-symbol-value-not-present.js | 29 ++++++++++++++ ...turns-false-when-value-cannot-be-held-weakly.js | 22 +++++++++++ .../has/returns-true-when-object-value-present.js | 20 ++++++++++ .../has/returns-true-when-symbol-value-present.js | 24 ++++++++++++ .../built-ins/WeakSet/prototype/has/shell.js | 0 .../prototype/has/this-not-object-throw-boolean.js | 23 +++++++++++ .../prototype/has/this-not-object-throw-null.js | 23 +++++++++++ .../prototype/has/this-not-object-throw-number.js | 23 +++++++++++ .../prototype/has/this-not-object-throw-string.js | 23 +++++++++++ .../prototype/has/this-not-object-throw-symbol.js | 23 +++++++++++ .../has/this-not-object-throw-undefined.js | 23 +++++++++++ .../WeakSet/prototype/prototype-attributes.js | 14 +++++++ .../test262/built-ins/WeakSet/prototype/shell.js | 0 js/src/tests/test262/built-ins/WeakSet/shell.js | 24 ++++++++++++ .../built-ins/WeakSet/undefined-newtarget.js | 22 +++++++++++ js/src/tests/test262/built-ins/WeakSet/weakset.js | 16 ++++++++ 97 files changed, 2145 insertions(+) create mode 100644 js/src/tests/test262/built-ins/WeakSet/add-not-callable-throws.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/browser.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/constructor.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/empty-iterable.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/get-add-method-failure.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/is-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/iterable-failure.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/iterable-with-object-values.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/iterable-with-symbol-values.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/iterator-close-after-add-failure.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/iterator-next-failure.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/iterator-value-failure.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/length.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/name.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/no-iterable.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/properties-of-the-weakset-prototype-object.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/proto-from-ctor-realm.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype-of-weakset.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/Symbol.toStringTag.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/add.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/adds-object-element.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/adds-symbol-element.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/browser.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-array.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-map.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-object.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-set.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-weakset-prototype.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/length.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/name.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-symbol.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate-symbol.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/shell.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-boolean.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-null.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-number.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-string.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-symbol.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-undefined.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/add/throw-when-value-cannot-be-held-weakly.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/browser.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/constructor/browser.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/constructor/shell.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor-intrinsic.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/browser.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-entry-initial-iterable.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-object-entry.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-symbol-entry.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-array.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-map.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-object.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-set.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-weakset-prototype.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/length.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/name.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/returns-false-when-delete-is-noop.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/returns-false-when-value-cannot-be-held-weakly.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/shell.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-boolean.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-null.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-number.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-string.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-symbol.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-undefined.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/browser.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-array.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-map.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-object.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-set.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-weakset-prototype.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/has.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/length.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/name.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-object-value-not-present.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-symbol-value-not-present.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-value-cannot-be-held-weakly.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-true-when-object-value-present.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-true-when-symbol-value-present.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/shell.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-boolean.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-null.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-number.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-string.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-symbol.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-undefined.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/prototype-attributes.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/prototype/shell.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/shell.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/undefined-newtarget.js create mode 100644 js/src/tests/test262/built-ins/WeakSet/weakset.js (limited to 'js/src/tests/test262/built-ins/WeakSet') diff --git a/js/src/tests/test262/built-ins/WeakSet/add-not-callable-throws.js b/js/src/tests/test262/built-ins/WeakSet/add-not-callable-throws.js new file mode 100644 index 0000000000..54f29d1fe0 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/add-not-callable-throws.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-weakset-iterable +description: > + Throws TypeError if add is not callable on constructor call. +info: | + 23.4.1.1 WeakSet ( [ iterable ] ) + + ... + 5. If iterable is not present, let iterable be undefined. + 6. If iterable is either undefined or null, let iter be undefined. + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + ... +---*/ + +WeakSet.prototype.add = null; +new WeakSet(); + +assert.throws(TypeError, function() { + new WeakSet([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/browser.js b/js/src/tests/test262/built-ins/WeakSet/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/constructor.js b/js/src/tests/test262/built-ins/WeakSet/constructor.js new file mode 100644 index 0000000000..21e8e80f7e --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/constructor.js @@ -0,0 +1,15 @@ +// 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-weakset-constructor +description: > + The WeakSet constructor is the %WeakSet% intrinsic object and the initial + value of the WeakSet property of the global object. +---*/ + +assert.sameValue( + typeof WeakSet, 'function', + 'typeof WeakSet is "function"' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/empty-iterable.js b/js/src/tests/test262/built-ins/WeakSet/empty-iterable.js new file mode 100644 index 0000000000..41ec8a90f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/empty-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. +/*--- +esid: sec-weakset-iterable +description: > + If the iterable argument is empty, return new Weakset object. +info: | + 23.4.1.1 WeakSet ( [ iterable ] ) + + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + ... +---*/ + +var counter = 0; +var add = WeakSet.prototype.add; +WeakSet.prototype.add = function(value) { + counter++; + return add.call(this, value); +}; +var set = new WeakSet([]); + +assert.sameValue(Object.getPrototypeOf(set), WeakSet.prototype); +assert(set instanceof WeakSet); +assert.sameValue( + counter, 0, + 'empty iterable does not call WeakSet.prototype.add' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/get-add-method-failure.js b/js/src/tests/test262/built-ins/WeakSet/get-add-method-failure.js new file mode 100644 index 0000000000..f81704d2fe --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/get-add-method-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. +/*--- +esid: sec-weakset-iterable +description: > + Return abrupt after getting `add` method. +info: | + 23.4.1.1 WeakSet ( [ iterable ] ) + + ... + 5. If iterable is not present, let iterable be undefined. + 6. If iterable is either undefined or null, let iter be undefined. + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + ... +---*/ + +Object.defineProperty(WeakSet.prototype, 'add', { + get: function() { + throw new Test262Error(); + } +}); + +new WeakSet(); +new WeakSet(null); + +assert.throws(Test262Error, function() { + new WeakSet([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/is-a-constructor.js b/js/src/tests/test262/built-ins/WeakSet/is-a-constructor.js new file mode 100644 index 0000000000..c8cdc19cb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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 WeakSet 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, WeakSet] +---*/ + +assert.sameValue(isConstructor(WeakSet), true, 'isConstructor(WeakSet) must return true'); +new WeakSet(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/iterable-failure.js b/js/src/tests/test262/built-ins/WeakSet/iterable-failure.js new file mode 100644 index 0000000000..87dc051cad --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/iterable-failure.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-weakset-iterable +description: > + If the iterable argument is undefined, return new Weakset object. +info: | + 23.4.1.1 WeakSet ( [ iterable ] ) + + ... + 7. Else, + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... +---*/ + +assert.throws(TypeError, function() { + new WeakSet({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/iterable-with-object-values.js b/js/src/tests/test262/built-ins/WeakSet/iterable-with-object-values.js new file mode 100644 index 0000000000..e5510b1455 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/iterable-with-object-values.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-weakset-iterable +description: > + Returns the new WeakSet adding Object values from the iterable parameter. +info: | + WeakSet ( [ _iterable_ ] ) + 8. Repeat, + d. Let _status_ be Completion(Call(_adder_, _set_, « _nextValue_ »)). + + WeakSet.prototype.add ( _value_ ): + 6. Append _value_ as the last element of _entries_. +features: [WeakSet] +---*/ + +var first = {}; +var second = {}; +var added = []; +var add = WeakSet.prototype.add; +WeakSet.prototype.add = function(value) { + added.push(value); + return add.call(this, value); +}; +var s = new WeakSet([first, second]); + +assert.sameValue(added.length, 2, 'Called WeakSet#add for each object'); +assert.sameValue(added[0], first, 'Adds object in order - first'); +assert.sameValue(added[1], second, 'Adds object in order - second'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/iterable-with-symbol-values.js b/js/src/tests/test262/built-ins/WeakSet/iterable-with-symbol-values.js new file mode 100644 index 0000000000..217438a5c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/iterable-with-symbol-values.js @@ -0,0 +1,37 @@ +// |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(release_or_beta||!xulRuntime.shell) -- symbols-as-weakmap-keys is not released yet, requires shell-options +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset-iterable +description: > + Returns the new WeakSet adding Symbol values from the iterable parameter. +info: | + WeakSet ( [ _iterable_ ] ) + 8. Repeat, + d. Let _status_ be Completion(Call(_adder_, _set_, « _nextValue_ »)). + + WeakSet.prototype.add ( _value_ ): + 6. Append _value_ as the last element of _entries_. +features: [Symbol, WeakSet, symbols-as-weakmap-keys] +includes: [compareArray.js] +---*/ + +var first = Symbol('a description'); +var second = Symbol('a description'); +var added = []; +var realAdd = WeakSet.prototype.add; +WeakSet.prototype.add = function(value) { + added.push(value); + return realAdd.call(this, value); +}; +var s = new WeakSet([first, second, Symbol.hasInstance]); + +assert.compareArray( + added, + [first, second, Symbol.hasInstance], + "add() was called 3 times, on the two unregistered and one well-known symbols in order" +); + +WeakSet.prototype.add = realAdd; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/iterator-close-after-add-failure.js b/js/src/tests/test262/built-ins/WeakSet/iterator-close-after-add-failure.js new file mode 100644 index 0000000000..90b8e8e813 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/iterator-close-after-add-failure.js @@ -0,0 +1,45 @@ +// 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-weakset-iterable +description: > + Return IteratorClose(iter, status) if fail on adding value on constructing. +info: | + WeakSet ( [ iterable ] ) + + ... + 9. Repeat + f. Let status be Call(adder, set, «nextValue»). + 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; + } + }; +}; +WeakSet.prototype.add = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + new WeakSet(iterable); +}); + +assert.sameValue( + count, 1, + 'The iterator is closed when `WeakSet.prototype.add` throws an error.' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/iterator-next-failure.js b/js/src/tests/test262/built-ins/WeakSet/iterator-next-failure.js new file mode 100644 index 0000000000..12925e2cb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/iterator-next-failure.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-weakset-iterable +description: > + Return abrupt from next iterator step. +info: | + 23.4.1.1 WeakSet ( [ iterable ] ) + + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + ... +features: [Symbol.iterator] +---*/ + +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + new WeakSet(iterable); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/iterator-value-failure.js b/js/src/tests/test262/built-ins/WeakSet/iterator-value-failure.js new file mode 100644 index 0000000000..284145a05d --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/iterator-value-failure.js @@ -0,0 +1,37 @@ +// 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-weakset-iterable +description: > + If the iterable argument is empty, return new Weakset object. +info: | + 23.4.1.1 WeakSet ( [ iterable ] ) + + ... + 9. Repeat + ... + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). +features: [Symbol.iterator] +---*/ + +var count = 0; +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + get value() { + throw new Test262Error(); + }, + done: false + }; + } + }; +}; + +assert.throws(Test262Error, function() { + new WeakSet(iterable); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/length.js b/js/src/tests/test262/built-ins/WeakSet/length.js new file mode 100644 index 0000000000..a34c33236d --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/length.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. +/*--- +esid: sec-properties-of-the-weakset-constructor +description: > + The length property of the WeakSet constructor is 0. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(WeakSet.length, 0, 'The value of `WeakSet.length` is `0`'); + +verifyNotEnumerable(WeakSet, 'length'); +verifyNotWritable(WeakSet, 'length'); +verifyConfigurable(WeakSet, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/name.js b/js/src/tests/test262/built-ins/WeakSet/name.js new file mode 100644 index 0000000000..dedd6f4fd0 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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. +/*--- +esid: sec-weakset-iterable +description: > + WeakSet ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakSet.name, 'WeakSet', + 'The value of `WeakSet.name` is "WeakSet"' +); + +verifyNotEnumerable(WeakSet, 'name'); +verifyNotWritable(WeakSet, 'name'); +verifyConfigurable(WeakSet, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/no-iterable.js b/js/src/tests/test262/built-ins/WeakSet/no-iterable.js new file mode 100644 index 0000000000..6413080507 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/no-iterable.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. +/*--- +esid: sec-weakset-iterable +description: > + If the iterable argument is undefined, return new Weakset object. +info: | + 23.4.1.1 WeakSet ( [ iterable ] ) + + ... + 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. + ... +---*/ + +var a = new WeakSet(); +var b = new WeakSet(undefined); +var c = new WeakSet(null); + +assert.sameValue(Object.getPrototypeOf(a), WeakSet.prototype); +assert.sameValue(Object.getPrototypeOf(b), WeakSet.prototype); +assert.sameValue(Object.getPrototypeOf(c), WeakSet.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/properties-of-the-weakset-prototype-object.js b/js/src/tests/test262/built-ins/WeakSet/properties-of-the-weakset-prototype-object.js new file mode 100644 index 0000000000..26f93b89c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/properties-of-the-weakset-prototype-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-properties-of-the-weakset-prototype-object +description: > + The WeakSet.prototype's prototype is Object.prototype. +info: | + 23.4.3 Properties of the WeakSet Prototype Object + + The WeakSet prototype object is the intrinsic object %WeakSetPrototype%. The + value of the [[Prototype]] internal slot of the WeakSet prototype object is + the intrinsic object %ObjectPrototype% (19.1.3). The WeakSet prototype + object is an ordinary object. It does not have a [[WeakSetData]] internal + slot. +---*/ + +assert.sameValue( + Object.getPrototypeOf(WeakSet.prototype), + Object.prototype, + '`Object.getPrototypeOf(WeakSet.prototype)` returns `Object.prototype`' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/WeakSet/proto-from-ctor-realm.js new file mode 100644 index 0000000000..94a58c6e7e --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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-weakset-iterable +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, + "%WeakSetPrototype%", « [[WeakSetData]] »). + [...] + + 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(WeakSet, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.WeakSet.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype-of-weakset.js b/js/src/tests/test262/built-ins/WeakSet/prototype-of-weakset.js new file mode 100644 index 0000000000..f46134d487 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype-of-weakset.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. +/*--- +esid: sec-properties-of-the-weakset-constructor +description: > + The value of the [[Prototype]] internal slot of the WeakSet constructor + is the intrinsic object %FunctionPrototype% (19.2.3). +---*/ + +assert.sameValue( + Object.getPrototypeOf(WeakSet), + Function.prototype, + '`Object.getPrototypeOf(WeakSet)` returns `Function.prototype`' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/Symbol.toStringTag.js b/js/src/tests/test262/built-ins/WeakSet/prototype/Symbol.toStringTag.js new file mode 100644 index 0000000000..46283bf20b --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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. +/*--- +esid: sec-weakset.prototype-@@tostringtag +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + "WeakSet". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +assert.sameValue(WeakSet.prototype[Symbol.toStringTag], 'WeakSet'); + +verifyNotEnumerable(WeakSet.prototype, Symbol.toStringTag); +verifyNotWritable(WeakSet.prototype, Symbol.toStringTag); +verifyConfigurable(WeakSet.prototype, Symbol.toStringTag); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/add.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/add.js new file mode 100644 index 0000000000..fdde051296 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/add.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-weakset.prototype.add +description: WeakSet.prototype.add property descriptor +info: | + WeakSet.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof WeakSet.prototype.add, + 'function', + 'typeof WeakSet.prototype.add is "function"' +); + +verifyNotEnumerable(WeakSet.prototype, 'add'); +verifyWritable(WeakSet.prototype, 'add'); +verifyConfigurable(WeakSet.prototype, 'add'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/adds-object-element.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/adds-object-element.js new file mode 100644 index 0000000000..89c946b923 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/adds-object-element.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. +/*--- +esid: sec-weakset.prototype.add +description: > + Adds an Object value. +info: | + WeakSet.prototype.add ( _value_ ) + 6. Append _value_ as the last element of _entries_. +features: [WeakSet] +---*/ + +var s = new WeakSet(); +var foo = {}; +var bar = {}; +var baz = {}; + +s.add(foo); +s.add(bar); +s.add(baz); + +assert(s.has(foo)); +assert(s.has(bar)); +assert(s.has(baz)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/adds-symbol-element.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/adds-symbol-element.js new file mode 100644 index 0000000000..b56ba8ae80 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/adds-symbol-element.js @@ -0,0 +1,27 @@ +// |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(release_or_beta||!xulRuntime.shell) -- symbols-as-weakmap-keys is not released yet, requires shell-options +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset.prototype.add +description: Adds a Symbol value. +info: | + WeakSet.prototype.add ( _value_ ) + 6. Append _value_ as the last element of _entries_. +features: [Symbol, WeakSet, symbols-as-weakmap-keys] +---*/ + +var s = new WeakSet(); +var foo = Symbol('a description'); +var bar = Symbol('a description'); +var baz = Symbol('a different description'); + +s.add(foo); +s.add(baz); +s.add(Symbol.hasInstance); + +assert(s.has(foo), 'Regular symbol'); +assert(!s.has(bar), "Symbols with the same description don't alias each other"); +assert(s.has(baz), 'Regular symbol with different description'); +assert(s.has(Symbol.hasInstance), 'Well-known symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/browser.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-array.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-array.js new file mode 100644 index 0000000000..ad6734e3dd --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-array.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. +/*--- +esid: sec-weakset.prototype.add +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.add ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... + +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.add.call([], {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call([], {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-map.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-map.js new file mode 100644 index 0000000000..7b8a340c4b --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-map.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. +/*--- +esid: sec-weakset.prototype.add +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.add ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... + +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.add.call(new Map(), {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call(new Map(), {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-object.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-object.js new file mode 100644 index 0000000000..3b54921c00 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-object.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. +/*--- +esid: sec-weakset.prototype.add +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.add ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... + +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.add.call({}, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call({}, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-set.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-set.js new file mode 100644 index 0000000000..93c7bbb218 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-set.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. +/*--- +esid: sec-weakset.prototype.add +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.add ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.add.call(new Set(), {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call(new Set(), {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-weakset-prototype.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-weakset-prototype.js new file mode 100644 index 0000000000..947d16e2fa --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-weakset-prototype.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. +/*--- +esid: sec-weakset.prototype.add +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.add ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... + +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.add.call(WeakSet.prototype, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call(WeakSet.prototype, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/length.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/length.js new file mode 100644 index 0000000000..7112319f12 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/length.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-weakset.prototype.add +description: WeakSet.prototype.add.length descriptor +info: | + WeakSet.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakSet.prototype.add.length, 1, + 'The value of `WeakSet.prototype.add.length` is `1`' +); + +verifyNotEnumerable(WeakSet.prototype.add, 'length'); +verifyNotWritable(WeakSet.prototype.add, 'length'); +verifyConfigurable(WeakSet.prototype.add, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/name.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/name.js new file mode 100644 index 0000000000..e81470dc1c --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/name.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-weakset.prototype.add +description: WeakSet.prototype.add.name descriptor +info: | + WeakSet.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakSet.prototype.add.name, 'add', + 'The value of WeakSet.prototype.add.name is "add"' +); + +verifyNotEnumerable(WeakSet.prototype.add, 'name'); +verifyNotWritable(WeakSet.prototype.add, 'name'); +verifyConfigurable(WeakSet.prototype.add, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/not-a-constructor.js new file mode 100644 index 0000000000..df2a033c51 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/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: > + WeakSet.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, WeakSet, arrow-function] +---*/ + +assert.sameValue( + isConstructor(WeakSet.prototype.add), + false, + 'isConstructor(WeakSet.prototype.add) must return false' +); + +assert.throws(TypeError, () => { + let ws = new WeakSet(); new ws.add({}); +}, '`let ws = new WeakSet(); new ws.add({})` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-symbol.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-symbol.js new file mode 100644 index 0000000000..f67e2cc524 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-symbol.js @@ -0,0 +1,21 @@ +// |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(release_or_beta||!xulRuntime.shell) -- symbols-as-weakmap-keys is not released yet, requires shell-options +// Copyright (C) 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weakset.prototype.add +description: Returns `this` after adding a new value. +info: | + WeakSet.prototype.add ( value ) + + 1. Let S be the this value. + ... + 7. Return S. +features: [Symbol, WeakSet, symbols-as-weakmap-keys] +---*/ + +var s = new WeakSet(); + +assert.sameValue(s.add(Symbol('description')), s, '`s.add(Symbol("description"))` returns `s`'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate-symbol.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate-symbol.js new file mode 100644 index 0000000000..442dcfb052 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate-symbol.js @@ -0,0 +1,25 @@ +// |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(release_or_beta||!xulRuntime.shell) -- symbols-as-weakmap-keys is not released yet, requires shell-options +// Copyright (C) 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-weakset.prototype.add +description: Returns `this` when new value is duplicate. +info: | + WeakSet.prototype.add ( value ) + + 1. Let S be the this value. + ... + 5. 5. For each element e of entries, do + a. If e is not empty and SameValue(e, value) is true, then + i. Return S. + ... +features: [Symbol, WeakSet, symbols-as-weakmap-keys] +---*/ + +var foo = Symbol('description'); +var s = new WeakSet([foo]); + +assert.sameValue(s.add(foo), s, '`s.add(foo)` returns `s`'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate.js new file mode 100644 index 0000000000..0757a57d08 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate.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-weakset.prototype.add +description: Returns `this` when new value is duplicate. +info: | + WeakSet.prototype.add ( value ) + + 1. Let S be this value. + ... + 6. 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 foo = {}; +var s = new WeakSet([foo]); + +assert.sameValue(s.add(foo), s, '`s.add(foo)` returns `s`'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this.js new file mode 100644 index 0000000000..36bc5d7ab6 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/returns-this.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-weakset.prototype.add +description: Returns `this` after adding a new value. +info: | + WeakSet.prototype.add ( value ) + + 1. Let S be this value. + ... + 8. Return S. + +---*/ + +var s = new WeakSet(); + +assert.sameValue(s.add({}), s, '`s.add({})` returns `s`'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/shell.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..1e42880bd0 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-boolean.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-weakset.prototype.add +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.add.call(false, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call(false, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-null.js new file mode 100644 index 0000000000..1177ac42d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-null.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-weakset.prototype.add +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.add.call(null, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call(null, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-number.js new file mode 100644 index 0000000000..84f4ba33d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-number.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-weakset.prototype.add +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.add.call(0, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call(0, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-string.js new file mode 100644 index 0000000000..851eabfdce --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-string.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-weakset.prototype.add +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.add.call('', {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call('', {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..a2346d5ed2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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-weakset.prototype.add +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.add.call(Symbol(), {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call(Symbol(), {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..6bb069cc3f --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/this-not-object-throw-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. +/*--- +esid: sec-weakset.prototype.add +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.add.call(undefined, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.add.call(undefined, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/add/throw-when-value-cannot-be-held-weakly.js b/js/src/tests/test262/built-ins/WeakSet/prototype/add/throw-when-value-cannot-be-held-weakly.js new file mode 100644 index 0000000000..d92f3a283b --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/add/throw-when-value-cannot-be-held-weakly.js @@ -0,0 +1,38 @@ +// 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-weakset.prototype.add +description: Throws TypeError if value cannot be held weakly. +info: | + WeakSet.prototype.add ( _value_ ) + 3. If CanBeHeldWeakly(_value_) is *false*, throw a *TypeError* exception. +features: [Symbol, WeakSet] +---*/ + +var s = new WeakSet(); + +assert.throws(TypeError, function() { + s.add(1); +}); + +assert.throws(TypeError, function() { + s.add(false); +}); + +assert.throws(TypeError, function() { + s.add(); +}); + +assert.throws(TypeError, function() { + s.add('string'); +}); + +assert.throws(TypeError, function() { + s.add(null); +}); + +assert.throws(TypeError, function() { + s.add(Symbol.for('registered symbol')); +}, 'Registered symbol not allowed as WeakSet value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/browser.js b/js/src/tests/test262/built-ins/WeakSet/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/constructor/browser.js b/js/src/tests/test262/built-ins/WeakSet/prototype/constructor/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/constructor/shell.js b/js/src/tests/test262/built-ins/WeakSet/prototype/constructor/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor-intrinsic.js b/js/src/tests/test262/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor-intrinsic.js new file mode 100644 index 0000000000..bc2d887649 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor-intrinsic.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. +/*--- +esid: sec-weakset.prototype.constructor +description: > + The initial value of WeakSet.prototype.constructor is the %WeakSet% + intrinsic object. +---*/ + +assert.sameValue( + WeakSet.prototype.constructor, + WeakSet, + 'The value of WeakSet.prototype.constructor is "WeakSet"' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor.js b/js/src/tests/test262/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor.js new file mode 100644 index 0000000000..4c4867f411 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor.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-weakset.prototype.constructor +description: > + WeakSet.prototype.constructor property descriptor +info: | + WeakSet ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(WeakSet.prototype, 'constructor'); +verifyWritable(WeakSet.prototype, 'constructor'); +verifyConfigurable(WeakSet.prototype, 'constructor'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/browser.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-entry-initial-iterable.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-entry-initial-iterable.js new file mode 100644 index 0000000000..be17a549fa --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-entry-initial-iterable.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset.prototype.delete +description: > + Delete an entry from initial iterable. +info: | + WeakSet.prototype.delete ( value ) + + ... + 5. Let entries be the List that is the value of S’s [[WeakSetData]] internal + slot. + 6. Repeat for each e that is an element of entries, + a. If e is not empty and SameValue(e, value) is true, then + i. Replace the element of entries whose value is e with an element whose + value is empty. + ii. Return true. + ... +---*/ + +var foo = {}; +var s = new WeakSet([foo]); + +var result = s.delete(foo); + +assert.sameValue(s.has(foo), false); +assert.sameValue(result, true, 'WeakSet#delete returns true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-object-entry.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-object-entry.js new file mode 100644 index 0000000000..419c0e9d11 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-object-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-weakset.prototype.delete +description: > + Delete an entry that is an Object +info: | + WeakSet.prototype.delete ( _value_ ) + 4. Let _entries_ be the List that is _S_.[[WeakSetData]]. + 5. For each element _e_ of _entries_, do + a. If _e_ is not ~empty~ and SameValue(_e_, _value_) is *true*, then + i. Replace the element of _entries_ whose value is _e_ with an element + whose value is ~empty~. + ii. Return *true*. +features: [WeakSet] +---*/ + +var foo = {}; +var s = new WeakSet(); + +s.add(foo); + +var result = s.delete(foo); + +assert.sameValue(s.has(foo), false); +assert.sameValue(result, true, 'WeakSet#delete returns true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-symbol-entry.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-symbol-entry.js new file mode 100644 index 0000000000..f4f81bb4f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete-symbol-entry.js @@ -0,0 +1,34 @@ +// |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(release_or_beta||!xulRuntime.shell) -- symbols-as-weakmap-keys is not released yet, requires shell-options +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset.prototype.delete +description: > + Delete an entry that is a Symbol +info: | + WeakSet.prototype.delete ( _value_ ) + 4. Let _entries_ be the List that is _S_.[[WeakSetData]]. + 5. For each element _e_ of _entries_, do + a. If _e_ is not ~empty~ and SameValue(_e_, _value_) is *true*, then + i. Replace the element of _entries_ whose value is _e_ with an element + whose value is ~empty~. + ii. Return *true*. +features: [Symbol, WeakSet, symbols-as-weakmap-keys] +---*/ + +var foo = Symbol('a description'); +var bar = Symbol('a description'); +var s = new WeakSet(); + +s.add(foo); +s.add(bar); +s.add(Symbol.hasInstance); + +assert.sameValue(s.delete(foo), true, 'Returns true for regular symbol'); +assert(!s.has(foo), 'Regular symbol is removed from set'); +assert(s.has(bar), 'Symbols with the same description are not aliased to each other'); + +assert.sameValue(s.delete(Symbol.hasInstance), true, 'Returns true for well-known symbol'); +assert(!s.has(Symbol.hasInstance), 'Well-known symbol is removed from set'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete.js new file mode 100644 index 0000000000..6a6a0c6567 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/delete.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. +/*--- +esid: sec-weakset.prototype.delete +description: > + WeakSet.prototype.delete property descriptor +info: | + WeakSet.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof WeakSet.prototype.delete, + 'function', + 'typeof WeakSet.prototype.delete is "function"' +); + +verifyNotEnumerable(WeakSet.prototype, 'delete'); +verifyWritable(WeakSet.prototype, 'delete'); +verifyConfigurable(WeakSet.prototype, 'delete'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-array.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-array.js new file mode 100644 index 0000000000..85af47a0c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-array.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. +/*--- +esid: sec-weakset.prototype.delete +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.delete ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.delete.call([], {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call([], {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-map.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-map.js new file mode 100644 index 0000000000..9b66219774 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-map.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. +/*--- +esid: sec-weakset.prototype.delete +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.delete ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.delete.call(new Map(), {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call(new Map(), {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-object.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-object.js new file mode 100644 index 0000000000..e8a65833cd --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-object.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. +/*--- +esid: sec-weakset.prototype.delete +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.delete ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.delete.call({}, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call({}, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-set.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-set.js new file mode 100644 index 0000000000..a870aacbb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-set.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. +/*--- +esid: sec-weakset.prototype.delete +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.delete ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.delete.call(new Set(), {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call(new Set(), {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-weakset-prototype.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-weakset-prototype.js new file mode 100644 index 0000000000..a50aa93aa9 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-weakset-prototype.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. +/*--- +esid: sec-weakset.prototype.delete +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.delete ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.delete.call(WeakSet.prototype, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call(WeakSet.prototype, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/length.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/length.js new file mode 100644 index 0000000000..516b074855 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/length.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset.prototype.delete +description: > + WeakSet.prototype.delete.length value and writability. +info: | + WeakSet.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakSet.prototype.delete.length, 1, + 'The value of WeakSet.prototype.delete.length is 1' +); + +verifyNotEnumerable(WeakSet.prototype.delete, 'length'); +verifyNotWritable(WeakSet.prototype.delete, 'length'); +verifyConfigurable(WeakSet.prototype.delete, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/name.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/name.js new file mode 100644 index 0000000000..b759002e7c --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset.prototype.delete +description: > + WeakSet.prototype.delete.name value and writability. +info: | + WeakSet.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakSet.prototype.delete.name, 'delete', + 'The value of WeakSet.prototype.delete.name is "delete"' +); + +verifyNotEnumerable(WeakSet.prototype.delete, 'name'); +verifyNotWritable(WeakSet.prototype.delete, 'name'); +verifyConfigurable(WeakSet.prototype.delete, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/not-a-constructor.js new file mode 100644 index 0000000000..3f5c5605d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/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: > + WeakSet.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, WeakSet, arrow-function] +---*/ + +assert.sameValue( + isConstructor(WeakSet.prototype.delete), + false, + 'isConstructor(WeakSet.prototype.delete) must return false' +); + +assert.throws(TypeError, () => { + let ws = new WeakSet(); new ws.delete(); +}, '`let ws = new WeakSet(); new ws.delete()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/returns-false-when-delete-is-noop.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/returns-false-when-delete-is-noop.js new file mode 100644 index 0000000000..a122d06edb --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/returns-false-when-delete-is-noop.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-weakset.prototype.delete +description: > + Return false if entry wasn't in the WeakSet. +info: | + WeakSet.prototype.delete ( value ) + + ... + 7. Return false. + +---*/ + +var s = new WeakSet(); + +assert.sameValue(s.delete({}), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/returns-false-when-value-cannot-be-held-weakly.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/returns-false-when-value-cannot-be-held-weakly.js new file mode 100644 index 0000000000..cdffefa60a --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/returns-false-when-value-cannot-be-held-weakly.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-weakset.prototype.delete +description: > + Return false if value cannot be held weakly. +info: | + WeakSet.prototype.delete ( _value_ ) + 3. If CanBeHeldWeakly(_value_) is *false*, return *false*. +features: [Symbol, WeakSet] +---*/ + +var s = new WeakSet(); + +assert.sameValue(s.delete(1), false); +assert.sameValue(s.delete(''), false); +assert.sameValue(s.delete(null), false); +assert.sameValue(s.delete(undefined), false); +assert.sameValue(s.delete(true), false); +assert.sameValue(s.delete(Symbol.for('registered symbol')), false, 'Registered symbol not allowed as value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/shell.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..77b60d78c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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-weakset.prototype.delete +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.delete.call(false, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call(false, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-null.js new file mode 100644 index 0000000000..728e010f90 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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-weakset.prototype.delete +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.delete.call(null, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call(null, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-number.js new file mode 100644 index 0000000000..01a602ee90 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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-weakset.prototype.delete +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.delete.call(0, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call(0, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-string.js new file mode 100644 index 0000000000..f7e89614b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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-weakset.prototype.delete +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.delete.call('', {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call('', {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..8e0144c3f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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-weakset.prototype.delete +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.delete.call(Symbol(), {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call(Symbol(), {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/WeakSet/prototype/delete/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..f0b2b22949 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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-weakset.prototype.delete +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.delete.call(undefined, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call(undefined, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/browser.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-array.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-array.js new file mode 100644 index 0000000000..daa590bb0b --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-array.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. +/*--- +esid: sec-weakset.prototype.has +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.has ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.has.call([], {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call([], {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-map.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-map.js new file mode 100644 index 0000000000..1d2bc18b93 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-map.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. +/*--- +esid: sec-weakset.prototype.has +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.has ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.has.call(new Map(), {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call(new Map(), {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-object.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-object.js new file mode 100644 index 0000000000..b8ffc9af21 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-object.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. +/*--- +esid: sec-weakset.prototype.has +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.has ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.has.call({}, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call({}, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-set.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-set.js new file mode 100644 index 0000000000..9058742811 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-set.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. +/*--- +esid: sec-weakset.prototype.has +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.has ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.has.call(new Set(), {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call(new Set(), {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-weakset-prototype.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-weakset-prototype.js new file mode 100644 index 0000000000..85b34cc559 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-weakset-prototype.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. +/*--- +esid: sec-weakset.prototype.has +description: > + Throws TypeError if context doesn't have a [[WeakSetData]] internal slot. +info: | + WeakSet.prototype.has ( value ) + + ... + 3. If S does not have a [[WeakSetData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + WeakSet.prototype.has.call(WeakSet.prototype, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call(WeakSet.prototype, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/has.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/has.js new file mode 100644 index 0000000000..9436ad778e --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/has.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. +/*--- +esid: sec-weakset.prototype.has +description: > + WeakSet.prototype.has property descriptor +info: | + WeakSet.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof WeakSet.prototype.has, + 'function', + 'typeof WeakSet.prototype.has is "function"' +); + +verifyNotEnumerable(WeakSet.prototype, 'has'); +verifyWritable(WeakSet.prototype, 'has'); +verifyConfigurable(WeakSet.prototype, 'has'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/length.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/length.js new file mode 100644 index 0000000000..5e4176a5cc --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/length.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset.prototype.has +description: > + WeakSet.prototype.has.length value and writability. +info: | + WeakSet.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakSet.prototype.has.length, 1, + 'The value of WeakSet.prototype.has.length is 1' +); + +verifyNotEnumerable(WeakSet.prototype.has, 'length'); +verifyNotWritable(WeakSet.prototype.has, 'length'); +verifyConfigurable(WeakSet.prototype.has, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/name.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/name.js new file mode 100644 index 0000000000..6fca676585 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset.prototype.has +description: > + WeakSet.prototype.has.name value and writability. +info: | + WeakSet.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + WeakSet.prototype.has.name, 'has', + 'The value of WeakSet.prototype.has.name is "has"' +); + +verifyNotEnumerable(WeakSet.prototype.has, 'name'); +verifyNotWritable(WeakSet.prototype.has, 'name'); +verifyConfigurable(WeakSet.prototype.has, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/not-a-constructor.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/not-a-constructor.js new file mode 100644 index 0000000000..b21d7cb36f --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/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: > + WeakSet.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, WeakSet, arrow-function] +---*/ + +assert.sameValue( + isConstructor(WeakSet.prototype.has), + false, + 'isConstructor(WeakSet.prototype.has) must return false' +); + +assert.throws(TypeError, () => { + let ws = new WeakSet(); new ws.has(); +}, '`let ws = new WeakSet(); new ws.has()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-object-value-not-present.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-object-value-not-present.js new file mode 100644 index 0000000000..61bb52e68b --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-object-value-not-present.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. +/*--- +esid: sec-weakset.prototype.has +description: > + Return false when an Object value is not present in the WeakSet entries. +info: | + WeakSet.prototype.has ( _value_ ) + 6. Return *false*. +features: [WeakSet] +---*/ + +var foo = {}; +var bar = {}; +var s = new WeakSet(); + +assert.sameValue(s.has(foo), false); + +s.add(foo); +assert.sameValue(s.has(bar), false); + +s.delete(foo); +assert.sameValue(s.has(foo), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-symbol-value-not-present.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-symbol-value-not-present.js new file mode 100644 index 0000000000..8c7c103a56 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-symbol-value-not-present.js @@ -0,0 +1,29 @@ +// |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(release_or_beta||!xulRuntime.shell) -- symbols-as-weakmap-keys is not released yet, requires shell-options +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset.prototype.has +description: > + Return false when a Symbol value is not present in the WeakSet entries. +info: | + WeakSet.prototype.has ( _value_ ) + 6. Return *false*. +features: [Symbol, WeakSet, symbols-as-weakmap-keys] +---*/ + +var foo = Symbol('a description'); +var bar = Symbol('a description'); +var s = new WeakSet(); + +assert.sameValue(s.has(foo), false, 'Set is initially empty of regular symbol'); +assert.sameValue(s.has(Symbol.hasInstance), false, 'Set is initially empty of well-known symbol'); + +s.add(foo); +assert.sameValue(s.has(bar), false, 'Symbols with the same description are not aliased to each other'); + +s.delete(foo); +assert.sameValue(s.has(foo), false, 'Set is again empty of regular symbol after deleting'); +s.delete(Symbol.hasInstance); +assert.sameValue(s.has(Symbol.hasInstance), false, 'Set is again empty of well-known symbol after deleting'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-value-cannot-be-held-weakly.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-value-cannot-be-held-weakly.js new file mode 100644 index 0000000000..257a3084e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-false-when-value-cannot-be-held-weakly.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-weakset.prototype.has +description: > + Returns false if value cannot be held weakly. +info: | + WeakSet.prototype.has ( _value_ ) + 4. If CanBeHeldWeakly(_value_) is *false*, return *false*. +features: [Symbol, WeakSet] +---*/ + +var s = new WeakSet(); + +assert.sameValue(s.has(1), false); +assert.sameValue(s.has(''), false); +assert.sameValue(s.has(null), false); +assert.sameValue(s.has(undefined), false); +assert.sameValue(s.has(true), false); +assert.sameValue(s.has(Symbol.for('registered symbol')), false, 'Registered symbol not allowed as value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-true-when-object-value-present.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-true-when-object-value-present.js new file mode 100644 index 0000000000..a573289c03 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-true-when-object-value-present.js @@ -0,0 +1,20 @@ +// 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-weakset.prototype.has +description: > + Returns true when an Object value is present in the WeakSet entries list. +info: | + WeakSet.prototype.has ( _value_ ) + 5. For each element _e_ of _entries_, do + a. If _e_ is not ~empty~ and SameValue(_e_, _value_) is *true*, return *true*. +features: [WeakSet] +---*/ + +var foo = {}; +var s = new WeakSet(); + +s.add(foo); +assert.sameValue(s.has(foo), true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-true-when-symbol-value-present.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-true-when-symbol-value-present.js new file mode 100644 index 0000000000..aeb65b532b --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/returns-true-when-symbol-value-present.js @@ -0,0 +1,24 @@ +// |reftest| shell-option(--enable-symbols-as-weakmap-keys) skip-if(release_or_beta||!xulRuntime.shell) -- symbols-as-weakmap-keys is not released yet, requires shell-options +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-weakset.prototype.has +description: > + Returns true when a Symbol value is present in the WeakSet entries list. +info: | + WeakSet.prototype.has ( _value_ ) + 5. For each element _e_ of _entries_, do + a. If _e_ is not ~empty~ and SameValue(_e_, _value_) is *true*, return *true*. +features: [Symbol, WeakSet, symbols-as-weakmap-keys] +---*/ + +var foo = Symbol('a description'); +var s = new WeakSet(); + +s.add(foo); +assert.sameValue(s.has(foo), true, 'Regular symbol as value'); + +s.add(Symbol.hasInstance); +assert.sameValue(s.has(Symbol.hasInstance), true, 'Well-known symbol as value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/shell.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..aa0ed435c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-boolean.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-weakset.prototype.has +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.has.call(false, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call(false, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-null.js new file mode 100644 index 0000000000..5d8c2507e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-null.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-weakset.prototype.has +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.has.call(null, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call(null, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-number.js new file mode 100644 index 0000000000..9ebc28ea00 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-number.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-weakset.prototype.has +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.has.call(0, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call(0, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-string.js new file mode 100644 index 0000000000..2be2567b3f --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-string.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-weakset.prototype.has +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.has.call('', {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call('', {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..24465cdc64 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/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. +/*--- +esid: sec-weakset.prototype.has +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.has.call(Symbol(), {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call(Symbol(), {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..33669f28b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/has/this-not-object-throw-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. +/*--- +esid: sec-weakset.prototype.has +description: Throws TypeError if `this` is not Object. +info: | + WeakSet.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() { + WeakSet.prototype.has.call(undefined, {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.has.call(undefined, {}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/prototype-attributes.js b/js/src/tests/test262/built-ins/WeakSet/prototype/prototype-attributes.js new file mode 100644 index 0000000000..682327d2a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/prototype/prototype-attributes.js @@ -0,0 +1,14 @@ +// 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-weakset.prototype +description: > + WeakSet.prototype is not writable, not enumerable and not configurable. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(WeakSet, 'prototype'); +verifyNotWritable(WeakSet, 'prototype'); +verifyNotConfigurable(WeakSet, 'prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/prototype/shell.js b/js/src/tests/test262/built-ins/WeakSet/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/WeakSet/shell.js b/js/src/tests/test262/built-ins/WeakSet/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/shell.js @@ -0,0 +1,24 @@ +// 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] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/WeakSet/undefined-newtarget.js b/js/src/tests/test262/built-ins/WeakSet/undefined-newtarget.js new file mode 100644 index 0000000000..1839b33d0b --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/undefined-newtarget.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-weakset-iterable +description: > + The WeakSet constructor is the %WeakSet% intrinsic object and the initial + value of the WeakSet property of the global object. +info: | + 23.4.1.1 WeakSet ( [ iterable ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + WeakSet(); +}); + +assert.throws(TypeError, function() { + WeakSet([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/WeakSet/weakset.js b/js/src/tests/test262/built-ins/WeakSet/weakset.js new file mode 100644 index 0000000000..06e46a27e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/WeakSet/weakset.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. +/*--- +esid: sec-weakset-iterable +description: > + WeakSet ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, 'WeakSet'); +verifyWritable(this, 'WeakSet'); +verifyConfigurable(this, 'WeakSet'); + +reportCompare(0, 0); -- cgit v1.2.3