diff --git a/test/built-ins/WeakSet/add-not-callable-throws.js b/test/built-ins/WeakSet/add-not-callable-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..2bc25a181403c9f3b0474f710618af746d2ca624 --- /dev/null +++ b/test/built-ins/WeakSet/add-not-callable-throws.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.1.1 +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([]); +}); diff --git a/test/built-ins/WeakSet/constructor.js b/test/built-ins/WeakSet/constructor.js new file mode 100644 index 0000000000000000000000000000000000000000..f4aa6a952f7514af16bd501622ed0e69e52e563b --- /dev/null +++ b/test/built-ins/WeakSet/constructor.js @@ -0,0 +1,13 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.1 +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"' +); diff --git a/test/built-ins/WeakSet/empty-iterable.js b/test/built-ins/WeakSet/empty-iterable.js new file mode 100644 index 0000000000000000000000000000000000000000..5f9d61a5922d44e833c7049ccf54d27350ee8ca8 --- /dev/null +++ b/test/built-ins/WeakSet/empty-iterable.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.1.1 +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' +); diff --git a/test/built-ins/WeakSet/get-add-method-failure.js b/test/built-ins/WeakSet/get-add-method-failure.js new file mode 100644 index 0000000000000000000000000000000000000000..6f65bbbda5f1f08c15a3197e36e83f42a3fafdf0 --- /dev/null +++ b/test/built-ins/WeakSet/get-add-method-failure.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.1.1 +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([]); +}); diff --git a/test/built-ins/WeakSet/iterable-failure.js b/test/built-ins/WeakSet/iterable-failure.js new file mode 100644 index 0000000000000000000000000000000000000000..865d4b3c44b39e7467034cff24e29bc000739634 --- /dev/null +++ b/test/built-ins/WeakSet/iterable-failure.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.1.1 +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({}); +}); diff --git a/test/built-ins/WeakSet/iterable.js b/test/built-ins/WeakSet/iterable.js new file mode 100644 index 0000000000000000000000000000000000000000..14db16bed9a8cf2756d23ad03b09fbedcd5b274a --- /dev/null +++ b/test/built-ins/WeakSet/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. +/*--- +es6id: 23.4.1.1 +description: > + Returns the new WeakSet adding the objects from the iterable parameter. +info: > + WeakSet ( [ iterable ] ) + + ... + 9. Repeat + f. Let status be Call(adder, set, «nextValue»). + g. If status is an abrupt completion, return IteratorClose(iter, status). +includes: [compareArray.js] +---*/ + +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'); diff --git a/test/built-ins/WeakSet/iterator-close-after-add-failure.js b/test/built-ins/WeakSet/iterator-close-after-add-failure.js new file mode 100644 index 0000000000000000000000000000000000000000..7ea91410d036b5ad29f58a3d4512f43c7be88d7b --- /dev/null +++ b/test/built-ins/WeakSet/iterator-close-after-add-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. +/*--- +es6id: 23.4.1.1 +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). +---*/ + +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.' +); diff --git a/test/built-ins/WeakSet/iterator-next-failure.js b/test/built-ins/WeakSet/iterator-next-failure.js new file mode 100644 index 0000000000000000000000000000000000000000..ccb3c2ca3ee77dc6369b9c7d6f8136904f3ad580 --- /dev/null +++ b/test/built-ins/WeakSet/iterator-next-failure.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.1.1 +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). + ... +---*/ + +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + new WeakSet(iterable); +}); diff --git a/test/built-ins/WeakSet/iterator-value-failure.js b/test/built-ins/WeakSet/iterator-value-failure.js new file mode 100644 index 0000000000000000000000000000000000000000..eb13c04b460604ff40b4e05a4758849845f6dfc8 --- /dev/null +++ b/test/built-ins/WeakSet/iterator-value-failure.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.1.1 +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). +---*/ + +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); +}); diff --git a/test/built-ins/WeakSet/length.js b/test/built-ins/WeakSet/length.js new file mode 100644 index 0000000000000000000000000000000000000000..a8caa23e2e881ff84773a9eee30400e6a25574e8 --- /dev/null +++ b/test/built-ins/WeakSet/length.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. +/*--- +es6id: 23.4.2 +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'); diff --git a/test/built-ins/WeakSet/name.js b/test/built-ins/WeakSet/name.js new file mode 100644 index 0000000000000000000000000000000000000000..7cacba4420b3769284880da589fb0e53609e3150 --- /dev/null +++ b/test/built-ins/WeakSet/name.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. +/*--- +es6id: 23.4.1.1 +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'); diff --git a/test/built-ins/WeakSet/no-iterable.js b/test/built-ins/WeakSet/no-iterable.js new file mode 100644 index 0000000000000000000000000000000000000000..f3ff681a2d17eb9d1ffba8811fd96d7bf06c040d --- /dev/null +++ b/test/built-ins/WeakSet/no-iterable.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.1.1 +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); diff --git a/test/built-ins/WeakSet/properties-of-the-weakset-prototype-object.js b/test/built-ins/WeakSet/properties-of-the-weakset-prototype-object.js new file mode 100644 index 0000000000000000000000000000000000000000..b71d698326ce3193a4aca6a4d4cec6e0f4572cfa --- /dev/null +++ b/test/built-ins/WeakSet/properties-of-the-weakset-prototype-object.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3 +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`' +); diff --git a/test/built-ins/WeakSet/prototype-of-weakset.js b/test/built-ins/WeakSet/prototype-of-weakset.js new file mode 100644 index 0000000000000000000000000000000000000000..e9389ac13c72faa7ce9b081af0b6aba1ba2d6580 --- /dev/null +++ b/test/built-ins/WeakSet/prototype-of-weakset.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. +/*--- +es6id: 23.4.2 +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`' +); diff --git a/test/built-ins/WeakSet/prototype/Symbol.toStringTag/property-descriptor.js b/test/built-ins/WeakSet/prototype/Symbol.toStringTag/property-descriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..22637245d7acf799ad65441d97b498ba5c3ef031 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/Symbol.toStringTag/property-descriptor.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.5 +description: "WeakSet#@@toStringTag value and writability" +info: > + 23.4.3.5 WeakSet.prototype [ @@toStringTag ] + + 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] + ---*/ + +var WeakSetProto = WeakSet.prototype; + +assert.sameValue( + WeakSetProto[Symbol.toStringTag], + 'WeakSet', + 'The value of WeakSet.prototype[Symbol.toStringTag] is "WeakSet"' +); + +verifyNotEnumerable(WeakSetProto, Symbol.toStringTag); +verifyNotWritable(WeakSetProto, Symbol.toStringTag); +verifyConfigurable(WeakSetProto, Symbol.toStringTag); diff --git a/test/built-ins/WeakSet/prototype/add/add.js b/test/built-ins/WeakSet/prototype/add/add.js new file mode 100644 index 0000000000000000000000000000000000000000..6c76c71d94fcf48a0f628d71dd75695b39384d4e --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/add.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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'); diff --git a/test/built-ins/WeakSet/prototype/add/adds-element.js b/test/built-ins/WeakSet/prototype/add/adds-element.js new file mode 100644 index 0000000000000000000000000000000000000000..1f491806fda44b9ee5ec41dfd216e0327d93d4cd --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/adds-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. +/*--- +es6id: 23.4.3.1 +description: > + Appends value as the last element of entries. +info: > + WeakSet.prototype.add ( value ) + + ... + 7. Append value as the last element of entries. + ... +---*/ + +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)); diff --git a/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-array.js b/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-array.js new file mode 100644 index 0000000000000000000000000000000000000000..81e458bd55be782b4096992472a926808268e48a --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-array.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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([], {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-map.js b/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-map.js new file mode 100644 index 0000000000000000000000000000000000000000..26aafb60b15913e80dbd24c19bca9ac6676f12bd --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-map.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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(), {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-object.js b/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-object.js new file mode 100644 index 0000000000000000000000000000000000000000..2b13e930cc2a7b5ef5989e685512c1619045d45a --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-object.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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({}, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-set.js b/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-set.js new file mode 100644 index 0000000000000000000000000000000000000000..a1b248d2675b03e042191aef2f17095bb2e415a0 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-set.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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(), {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-weakset-prototype.js b/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-weakset-prototype.js new file mode 100644 index 0000000000000000000000000000000000000000..d4f285aa8fde2fd113860b906c7c24118a23f6af --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/does-not-have-weaksetdata-internal-slot-weakset-prototype.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/length.js b/test/built-ins/WeakSet/prototype/add/length.js new file mode 100644 index 0000000000000000000000000000000000000000..3e7838bace5a5a68b693871a1147012cb4d42c64 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/length.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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'); diff --git a/test/built-ins/WeakSet/prototype/add/name.js b/test/built-ins/WeakSet/prototype/add/name.js new file mode 100644 index 0000000000000000000000000000000000000000..b88aa93f78ddceeb14fa89850a6960a6f7fbd3c0 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/name.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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'); diff --git a/test/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate.js b/test/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate.js new file mode 100644 index 0000000000000000000000000000000000000000..d7363bb184d60e0d6b583204ee41055a4e0c84e0 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/returns-this-when-ignoring-duplicate.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. +/*--- +es6id: 23.4.3.1 +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`'); diff --git a/test/built-ins/WeakSet/prototype/add/returns-this.js b/test/built-ins/WeakSet/prototype/add/returns-this.js new file mode 100644 index 0000000000000000000000000000000000000000..789ccbd53d92df9eddb9a321a98e3a7048a973d9 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/returns-this.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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`'); diff --git a/test/built-ins/WeakSet/prototype/add/this-not-object-throw-boolean.js b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-boolean.js new file mode 100644 index 0000000000000000000000000000000000000000..0c0683b1326089eab6f1353521c71c21f4b3d9ab --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-boolean.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/this-not-object-throw-null.js b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-null.js new file mode 100644 index 0000000000000000000000000000000000000000..369e7daf8d25c3fe66c45ebfe62b70fc14b44b45 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-null.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/this-not-object-throw-number.js b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-number.js new file mode 100644 index 0000000000000000000000000000000000000000..0ce12e338e3d465877f8fbd1a5834d786f1f2841 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-number.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/this-not-object-throw-string.js b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-string.js new file mode 100644 index 0000000000000000000000000000000000000000..d2390d5405bec5b319e38b527536d659df43313b --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-string.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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('', {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/this-not-object-throw-symbol.js b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-symbol.js new file mode 100644 index 0000000000000000000000000000000000000000..d54f84ef0d55c185fe7f0b5a8fdd710931f3b155 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-symbol.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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(), {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/this-not-object-throw-undefined.js b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..daf6c2393dc74ab592cd156a2d7ad1bc1b157444 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/this-not-object-throw-undefined.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.1 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/add/value-not-object-throw.js b/test/built-ins/WeakSet/prototype/add/value-not-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..622a6e5d4c2cdcadf5eb02d64712689b80c2ec67 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/add/value-not-object-throw.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. +/*--- +es6id: 23.4.3.1 +description: Throws TypeError if `value` is not Object. +info: > + WeakSet.prototype.add ( value ) + + 4. If Type(value) is not Object, throw a TypeError exception. +features: [Symbol] +---*/ + +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()); +}); diff --git a/test/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor-intrinsic.js b/test/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor-intrinsic.js new file mode 100644 index 0000000000000000000000000000000000000000..5eb8862f6695ee41feacc35dc5d4d0e523f24704 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor-intrinsic.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. +/*--- +es6id: 23.4.3.2 +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"' +); diff --git a/test/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor.js b/test/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor.js new file mode 100644 index 0000000000000000000000000000000000000000..5773f7eed3140c52511192f7316ace8e8b15972d --- /dev/null +++ b/test/built-ins/WeakSet/prototype/constructor/weakset-prototype-constructor.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.2 +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'); diff --git a/test/built-ins/WeakSet/prototype/delete/delete-entry-initial-iterable.js b/test/built-ins/WeakSet/prototype/delete/delete-entry-initial-iterable.js new file mode 100644 index 0000000000000000000000000000000000000000..02e2845a4722530f1380875004bccead53a9c7f8 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/delete-entry-initial-iterable.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +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'); diff --git a/test/built-ins/WeakSet/prototype/delete/delete-entry.js b/test/built-ins/WeakSet/prototype/delete/delete-entry.js new file mode 100644 index 0000000000000000000000000000000000000000..286c2693c25a238d591da9972cfd689ebadfa441 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/delete-entry.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +description: > + Delete an entry. +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(); + +s.add(foo); + +var result = s.delete(foo); + +assert.sameValue(s.has(foo), false); +assert.sameValue(result, true, 'WeakSet#delete returns true'); \ No newline at end of file diff --git a/test/built-ins/WeakSet/prototype/delete/delete.js b/test/built-ins/WeakSet/prototype/delete/delete.js new file mode 100644 index 0000000000000000000000000000000000000000..0e5c9bb3fc27c0be656e3736b17b0b006823b128 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/delete.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +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'); diff --git a/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-array.js b/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-array.js new file mode 100644 index 0000000000000000000000000000000000000000..f90157dd8e28a2c4f885bac90c9421ad40abbdc9 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-array.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +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([], {}); +}); diff --git a/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-map.js b/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-map.js new file mode 100644 index 0000000000000000000000000000000000000000..f779e09da6e071c9abfa3e062b159b4a221c4c92 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-map.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +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(), {}); +}); diff --git a/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-object.js b/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-object.js new file mode 100644 index 0000000000000000000000000000000000000000..7758d011391fb283a4529080a364219e14fc0ea5 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-object.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +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({}, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-set.js b/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-set.js new file mode 100644 index 0000000000000000000000000000000000000000..c18918a336ec74b3af10dee46d2123ba9e2a8a94 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-set.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +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(), {}); +}); diff --git a/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-weakset-prototype.js b/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-weakset-prototype.js new file mode 100644 index 0000000000000000000000000000000000000000..276472ff28296aa8a1d9dbdd460d2cb2e58b9d05 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/does-not-have-weaksetdata-internal-slot-weakset-prototype.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/delete/length.js b/test/built-ins/WeakSet/prototype/delete/length.js new file mode 100644 index 0000000000000000000000000000000000000000..37ed98ddfa31251c0c0fa01cb79e05a978c82b7b --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/length.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +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'); diff --git a/test/built-ins/WeakSet/prototype/delete/name.js b/test/built-ins/WeakSet/prototype/delete/name.js new file mode 100644 index 0000000000000000000000000000000000000000..83f7e6b004642edc530ea13c7ab1ad04f71af7d0 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/name.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +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'); diff --git a/test/built-ins/WeakSet/prototype/delete/returns-false-value-is-not-object.js b/test/built-ins/WeakSet/prototype/delete/returns-false-value-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..f832e6d066ae9e3ce07fb3527ea0623bf95feea5 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/returns-false-value-is-not-object.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +description: > + Return false if value is not a non-null Object. +info: > + WeakSet.prototype.delete ( value ) + + 4. If Type(value) is not Object, return false. +features: [Symbol] +---*/ + +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()), false); diff --git a/test/built-ins/WeakSet/prototype/delete/returns-false-when-delete-is-noop.js b/test/built-ins/WeakSet/prototype/delete/returns-false-when-delete-is-noop.js new file mode 100644 index 0000000000000000000000000000000000000000..9c549cd96a0ff919bd80c18c48cb6a6331344c08 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/returns-false-when-delete-is-noop.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.3 +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); diff --git a/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-boolean.js b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-boolean.js new file mode 100644 index 0000000000000000000000000000000000000000..6e7beed6b432133b0308b575c04794ca4aeb4fc9 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-boolean.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. +/*--- +es6id: 23.4.3.3 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-null.js b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-null.js new file mode 100644 index 0000000000000000000000000000000000000000..f71201387f6326d59b7bd0d8943f2969e799519a --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-null.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. +/*--- +es6id: 23.4.3.3 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-number.js b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-number.js new file mode 100644 index 0000000000000000000000000000000000000000..7abf01627537cfc00f09e5dbf2b2d83d8160f7f1 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-number.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. +/*--- +es6id: 23.4.3.3 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-string.js b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-string.js new file mode 100644 index 0000000000000000000000000000000000000000..a91650db8cddc469d2db3e9b3e018ce20ee90484 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-string.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. +/*--- +es6id: 23.4.3.3 +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('', {}); +}); diff --git a/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-symbol.js b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-symbol.js new file mode 100644 index 0000000000000000000000000000000000000000..76df4a419e35872dee3ee319c84ee98532149121 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-symbol.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. +/*--- +es6id: 23.4.3.3 +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(Symbol(), {}); +}); + +assert.throws(TypeError, function() { + var s = new WeakSet(); + s.delete.call(Symbol(), {}); +}); diff --git a/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-undefined.js b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..9d816870b39e5b7ac4b30232573a69d4d3d8ea78 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/delete/this-not-object-throw-undefined.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. +/*--- +es6id: 23.4.3.3 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-array.js b/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-array.js new file mode 100644 index 0000000000000000000000000000000000000000..0fd9d989cfedcd2acaa740e1ec04d35bb66834d4 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-array.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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([], {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-map.js b/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-map.js new file mode 100644 index 0000000000000000000000000000000000000000..e821224378cd85d40e840cc989813591a178c762 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-map.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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(), {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-object.js b/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-object.js new file mode 100644 index 0000000000000000000000000000000000000000..058319b236e80cc9112678d26d1b661a7f54ddd8 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-object.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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({}, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-set.js b/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-set.js new file mode 100644 index 0000000000000000000000000000000000000000..e024db3f733bf680b68b685a7fb42bc3f20016b3 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-set.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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(), {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-weakset-prototype.js b/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-weakset-prototype.js new file mode 100644 index 0000000000000000000000000000000000000000..d21ef2180a37929b8db0b2186ec3d6edb63bb447 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/does-not-have-weaksetdata-internal-slot-weakset-prototype.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/has.js b/test/built-ins/WeakSet/prototype/has/has.js new file mode 100644 index 0000000000000000000000000000000000000000..8a30652ff9e4425d180d9597de07699c6c16f660 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/has.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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'); diff --git a/test/built-ins/WeakSet/prototype/has/length.js b/test/built-ins/WeakSet/prototype/has/length.js new file mode 100644 index 0000000000000000000000000000000000000000..c8564f4d02f56558f2f979189c009c78954e4e9b --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/length.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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'); diff --git a/test/built-ins/WeakSet/prototype/has/name.js b/test/built-ins/WeakSet/prototype/has/name.js new file mode 100644 index 0000000000000000000000000000000000000000..ef8f1be9f257cfa0f1d24295ca7f59a200173552 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/name.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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'); diff --git a/test/built-ins/WeakSet/prototype/has/returns-false-when-value-is-not-object.js b/test/built-ins/WeakSet/prototype/has/returns-false-when-value-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..803da8bd370c24196a0513a4506e7876ac83cea5 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/returns-false-when-value-is-not-object.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +description: > + Returns false if value is not a non-null Object. +info: > + WeakSet.prototype.has ( value ) + + 5. If Type(value) is not Object, return false. +features: [Symbol] +---*/ + +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()), false); diff --git a/test/built-ins/WeakSet/prototype/has/returns-false-when-value-not-present.js b/test/built-ins/WeakSet/prototype/has/returns-false-when-value-not-present.js new file mode 100644 index 0000000000000000000000000000000000000000..e0a3efc8cc7354f2a2a89b50810284acbd620d5c --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/returns-false-when-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. +/*--- +es6id: 23.4.3.4 +description: > + Return false when value is not present in the WeakSet entries. +info: > + WeakSet.prototype.has ( value ) + + ... + 7. Return false. + +---*/ + +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); diff --git a/test/built-ins/WeakSet/prototype/has/returns-true-when-value-present.js b/test/built-ins/WeakSet/prototype/has/returns-true-when-value-present.js new file mode 100644 index 0000000000000000000000000000000000000000..7ef09dba34b3f02dfa6d4c3c73922b0fbfb367dc --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/returns-true-when-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. +/*--- +es6id: 23.4.3.4 +description: > + Returns true when value is present in the WeakSet entries list. +info: > + WeakSet.prototype.has ( value ) + + ... + 6. Repeat for each e that is an element of entries, + a. If e is not empty and SameValue(e, value) is true, return true. + ... +---*/ + +var foo = {}; +var s = new WeakSet(); + +s.add(foo); +assert.sameValue(s.has(foo), true); diff --git a/test/built-ins/WeakSet/prototype/has/this-not-object-throw-boolean.js b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-boolean.js new file mode 100644 index 0000000000000000000000000000000000000000..b5e99ab6d9d2e5190aae81db5f29ffa0cea45a4d --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-boolean.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/this-not-object-throw-null.js b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-null.js new file mode 100644 index 0000000000000000000000000000000000000000..4ea248c717550ab22b63dc9c617664ba3b495b32 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-null.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/this-not-object-throw-number.js b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-number.js new file mode 100644 index 0000000000000000000000000000000000000000..7b23eb999eb27681e245be151b86578e624b67c7 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-number.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/this-not-object-throw-string.js b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-string.js new file mode 100644 index 0000000000000000000000000000000000000000..315c5d240d959c7094aec538b552a1cb2ced7c7e --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-string.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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('', {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/this-not-object-throw-symbol.js b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-symbol.js new file mode 100644 index 0000000000000000000000000000000000000000..cecb82acbfbc1ddc501e914f1d9aec00a57fdcc6 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-symbol.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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(), {}); +}); diff --git a/test/built-ins/WeakSet/prototype/has/this-not-object-throw-undefined.js b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-undefined.js new file mode 100644 index 0000000000000000000000000000000000000000..b45fe70d6d62f2be60afd9b854a30f1c63af2a3f --- /dev/null +++ b/test/built-ins/WeakSet/prototype/has/this-not-object-throw-undefined.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.3.4 +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, {}); +}); diff --git a/test/built-ins/WeakSet/prototype/prototype-attributes.js b/test/built-ins/WeakSet/prototype/prototype-attributes.js new file mode 100644 index 0000000000000000000000000000000000000000..2d5f542469b6658528f09f1d5e5a91ab997b9841 --- /dev/null +++ b/test/built-ins/WeakSet/prototype/prototype-attributes.js @@ -0,0 +1,12 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 23.4.2.1 +description: > + WeakSet.prototype is not writable, not enumerable and not configurable. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(WeakSet, 'prototype'); +verifyNotWritable(WeakSet, 'prototype'); +verifyNotConfigurable(WeakSet, 'prototype'); diff --git a/test/built-ins/WeakSet/symbol-disallowed-as-weakset-key.js b/test/built-ins/WeakSet/symbol-disallowed-as-weakset-key.js index 64cb1862bf8476f762e8f4427b14dfcf0c03aa64..ad3e91ffe8c99582040195510959ac31b88be5ee 100644 --- a/test/built-ins/WeakSet/symbol-disallowed-as-weakset-key.js +++ b/test/built-ins/WeakSet/symbol-disallowed-as-weakset-key.js @@ -3,7 +3,7 @@ /*--- es6id: 23.4.3.1_S2 description: > - Symbol may not be used as a WeakSet entry + Symbol may not be used as a WeakSet entry features: [WeakSet] ---*/ var weakset = new WeakSet(); diff --git a/test/built-ins/WeakSet/undefined-newtarget.js b/test/built-ins/WeakSet/undefined-newtarget.js new file mode 100644 index 0000000000000000000000000000000000000000..c25a85bcdefd1d05123fadf12fecd1ade7fdb74e --- /dev/null +++ b/test/built-ins/WeakSet/undefined-newtarget.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. +/*--- +es6id: 23.4.1.1 +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([]); +}); diff --git a/test/built-ins/WeakSet/weakset.js b/test/built-ins/WeakSet/weakset.js new file mode 100644 index 0000000000000000000000000000000000000000..312581668c2dfaf39085f4c44867e1ca194be27f --- /dev/null +++ b/test/built-ins/WeakSet/weakset.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. +/*--- +es6id: 23.4.1.1 +description: > + WeakSet ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, 'WeakSet'); +verifyWritable(this, 'WeakSet'); +verifyConfigurable(this, 'WeakSet');