diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Set/prototype/clear | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Set/prototype/clear')
21 files changed, 438 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/browser.js b/js/src/tests/test262/built-ins/Set/prototype/clear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/browser.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clear.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clear.js new file mode 100644 index 0000000000..802c67227a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clear.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Set.prototype.clear, + "function", + "`typeof Set.prototype.clear` is `'function'`" +); + +verifyNotEnumerable(Set.prototype, "clear"); +verifyWritable(Set.prototype, "clear"); +verifyConfigurable(Set.prototype, "clear"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents-from-iterable.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents-from-iterable.js new file mode 100644 index 0000000000..5b0c5adbd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents-from-iterable.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new Set([1, 2, 3]); + +assert.sameValue(s.size, 3, "The value of `s.size` is `3`"); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.clear()`"); +assert.sameValue(s.has(1), false, "`s.has(1)` returns `false`"); +assert.sameValue(s.has(2), false, "`s.has(2)` returns `false`"); +assert.sameValue(s.has(3), false, "`s.has(3)` returns `false`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents.js new file mode 100644 index 0000000000..44c4ecf59b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-all-contents.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new Set(); + +s.add(1).add(2).add(3); + +assert.sameValue(s.size, 3, "The value of `s.size` is `3`"); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.clear()`"); +assert.sameValue(s.has(1), false, "`s.has(1)` returns `false`"); +assert.sameValue(s.has(2), false, "`s.has(2)` returns `false`"); +assert.sameValue(s.has(3), false, "`s.has(3)` returns `false`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/clears-an-empty-set.js b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-an-empty-set.js new file mode 100644 index 0000000000..47fe4dd05b --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/clears-an-empty-set.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new Set(); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 0000000000..a892c1d9d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call([]); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 0000000000..4177ce9c6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(new Map()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(new Map()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 0000000000..fc0ac57bd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call({}); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js new file mode 100644 index 0000000000..b13aee60b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(Set.prototype); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(Set.prototype); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 0000000000..e693c1e5bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 3. If S does not have a [[SetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(new WeakSet()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(new WeakSet()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/length.js b/js/src/tests/test262/built-ins/Set/prototype/clear/length.js new file mode 100644 index 0000000000..84e1dd1146 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/length.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.clear.length, 0, "The value of `Set.prototype.clear.length` is `0`"); + +verifyNotEnumerable(Set.prototype.clear, "length"); +verifyNotWritable(Set.prototype.clear, "length"); +verifyConfigurable(Set.prototype.clear, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/name.js b/js/src/tests/test262/built-ins/Set/prototype/clear/name.js new file mode 100644 index 0000000000..722a8af8f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/name.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Set.prototype.clear.name, "clear", "The value of `Set.prototype.clear.name` is `'clear'`"); + +verifyNotEnumerable(Set.prototype.clear, "name"); +verifyNotWritable(Set.prototype.clear, "name"); +verifyConfigurable(Set.prototype.clear, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js b/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js new file mode 100644 index 0000000000..16f0ebd97c --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Set.prototype.clear does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, Set, arrow-function] +---*/ + +assert.sameValue(isConstructor(Set.prototype.clear), false, 'isConstructor(Set.prototype.clear) must return false'); + +assert.throws(TypeError, () => { + let s = new Set([]); new s.clear(); +}, '`let s = new Set([]); new s.clear()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/returns-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/clear/returns-undefined.js new file mode 100644 index 0000000000..8857aa8a85 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/returns-undefined.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + ... + 6. Return undefined. + +---*/ + +var s = new Set(); + +assert.sameValue(s.clear(), undefined, "`s.clear()` returns `undefined`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/shell.js b/js/src/tests/test262/built-ins/Set/prototype/clear/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/shell.js diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-boolean.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-boolean.js new file mode 100644 index 0000000000..8b8a18b1ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-boolean.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(false); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(false); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-null.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-null.js new file mode 100644 index 0000000000..c21931f3e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-null.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(null); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-number.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-number.js new file mode 100644 index 0000000000..211fa883ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-number.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(0); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(0); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-string.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-string.js new file mode 100644 index 0000000000..8097a19afa --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-string.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(""); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(""); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-symbol.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-symbol.js new file mode 100644 index 0000000000..3b284170fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-symbol.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-undefined.js b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-undefined.js new file mode 100644 index 0000000000..35b9fc665a --- /dev/null +++ b/js/src/tests/test262/built-ins/Set/prototype/clear/this-not-object-throw-undefined.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-set.prototype.clear +description: > + Set.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + Set.prototype.clear.call(undefined); +}); + +assert.throws(TypeError, function() { + var s = new Set(); + s.clear.call(undefined); +}); + +reportCompare(0, 0); |