mirror of https://github.com/tc39/test262.git
23.2 Set Objects
commit c56030aea7b3e43f46dbbc2b52859ca275cff226 Author: Rick Waldron <waldron.rick@gmail.com> Date: Thu Apr 30 15:17:44 2015 -0400 Fix nits commit 9b341022a9fd5a295ce85b630886dae10e10b653 Author: Rick Waldron <waldron.rick@gmail.com> Date: Tue Apr 28 13:52:04 2015 -0400 Wrap expected construct failure in assert.throws commit 9ef7e1c0499a99b15c64bb480dbfa41433cf9804 Author: Mike Pennisi <mike@mikepennisi.com> Date: Fri Apr 24 13:46:02 2015 -0400 Introduce addition tests for the Set constructor commit bd54cccf4a599c123fae5c97782f5562cd9da8a0 Author: Rick Waldron <waldron.rick@gmail.com> Date: Fri Apr 24 15:11:19 2015 -0400 23.2 Set Objects, additions commit 970e2ca95879161a8bb124ec712f7333fdea6798 Author: Rick Waldron <waldron.rick@gmail.com> Date: Tue Apr 21 12:44:41 2015 -0400 23.2 Set Objects
This commit is contained in:
parent
cd53869494
commit
6b3585451a
|
@ -0,0 +1,10 @@
|
|||
// 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.2.1
|
||||
description: >
|
||||
The Set constructor is the %Set% intrinsic object and the
|
||||
initial value of the Set property of the global object.
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Set, "function", "`typeof Set` is `'function'`");
|
|
@ -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.2.2
|
||||
description: >
|
||||
Properties of the Set Constructor
|
||||
|
||||
Besides the length property (whose value is 0)
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Set.length, 0, "The value of `Set.length` is `0`");
|
||||
|
||||
verifyNotEnumerable(Set, "length");
|
||||
verifyNotWritable(Set, "length");
|
||||
verifyConfigurable(Set, "length");
|
|
@ -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.2.1.1
|
||||
description: >
|
||||
Set ( [ iterable ] )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Set.name, "Set", "The value of `Set.name` is `'Set'`");
|
||||
|
||||
verifyNotEnumerable(Set, "name");
|
||||
verifyNotWritable(Set, "name");
|
||||
verifyConfigurable(Set, "name");
|
|
@ -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.2.3
|
||||
description: >
|
||||
The Set prototype object is the intrinsic object %SetPrototype%.
|
||||
The value of the [[Prototype]] internal slot of the Set prototype
|
||||
object is the intrinsic object %ObjectPrototype% (19.1.3). The Set
|
||||
prototype object is an ordinary object. It does not have a
|
||||
[[SetData]] internal slot.
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(Set.prototype),
|
||||
Object.prototype,
|
||||
"`Object.getPrototypeOf(Set.prototype)` returns `Object.prototype`"
|
||||
);
|
|
@ -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.2.2
|
||||
description: >
|
||||
The value of the [[Prototype]] internal slot of the Set constructor
|
||||
is the intrinsic object %FunctionPrototype% (19.2.3).
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(Set),
|
||||
Function.prototype,
|
||||
"`Object.getPrototypeOf(Set)` returns `Function.prototype`"
|
||||
);
|
|
@ -11,7 +11,11 @@
|
|||
|
||||
var SetIteratorProto = Object.getPrototypeOf(new Set()[Symbol.iterator]());
|
||||
|
||||
assert.sameValue('Set Iterator', SetIteratorProto[Symbol.toStringTag]);
|
||||
assert.sameValue(
|
||||
'Set Iterator',
|
||||
SetIteratorProto[Symbol.toStringTag],
|
||||
"`'Set Iterator'` is `SetIteratorProto[Symbol.toStringTag]`"
|
||||
);
|
||||
|
||||
verifyNotEnumerable(SetIteratorProto, Symbol.toStringTag);
|
||||
verifyNotWritable(SetIteratorProto, Symbol.toStringTag);
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
`Object.prototype.getOwnPropertyDescriptor` should reflect the value and
|
||||
writability of the @@toStringTag attribute.
|
||||
includes: [propertyHelper.js]
|
||||
es6id: 23.2.3.12
|
||||
---*/
|
||||
|
||||
var SetProto = Object.getPrototypeOf(new Set());
|
||||
|
||||
assert.sameValue(
|
||||
SetProto[Symbol.toStringTag],
|
||||
'Set',
|
||||
"The value of `SetProto[Symbol.toStringTag]` is `'Set'`"
|
||||
);
|
||||
|
||||
verifyNotEnumerable(SetProto, Symbol.toStringTag);
|
||||
verifyNotWritable(SetProto, Symbol.toStringTag);
|
||||
verifyConfigurable(SetProto, Symbol.toStringTag);
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Set.prototype.add,
|
||||
"function",
|
||||
"`typeof Set.prototype.add` is `'function'`"
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Set.prototype, "add");
|
||||
verifyWritable(Set.prototype, "add");
|
||||
verifyConfigurable(Set.prototype, "add");
|
21
test/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js
vendored
Normal file
21
test/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js
vendored
Normal file
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call([], 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call([], 1);
|
||||
});
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call(new Map(), 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call(new Map(), 1);
|
||||
});
|
21
test/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js
vendored
Normal file
21
test/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js
vendored
Normal file
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call({}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call({}, 1);
|
||||
});
|
21
test/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js
vendored
Normal file
21
test/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js
vendored
Normal file
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call(Set.prototype, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call(Set.prototype, 1);
|
||||
});
|
21
test/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js
vendored
Normal file
21
test/built-ins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js
vendored
Normal file
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call(new WeakSet(), 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call(new WeakSet(), 1);
|
||||
});
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Set.prototype.add.length, 1, "The value of `Set.prototype.add.length` is `1`");
|
||||
|
||||
verifyNotEnumerable(Set.prototype.add, "length");
|
||||
verifyNotWritable(Set.prototype.add, "length");
|
||||
verifyConfigurable(Set.prototype.add, "length");
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Set.prototype.add.name, "add", "The value of `Set.prototype.add.name` is `'add'`");
|
||||
|
||||
verifyNotEnumerable(Set.prototype.add, "name");
|
||||
verifyNotWritable(Set.prototype.add, "name");
|
||||
verifyConfigurable(Set.prototype.add, "name");
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
...
|
||||
7. Append value as the last element of entries.
|
||||
...
|
||||
---*/
|
||||
|
||||
var s = new Set();
|
||||
var expects = [1, 2, 3];
|
||||
|
||||
s.add(1).add(2).add(3);
|
||||
|
||||
s.forEach(function(value) {
|
||||
assert.sameValue(value, expects.shift());
|
||||
});
|
||||
|
||||
assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`");
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
1. Let S be this value.
|
||||
...
|
||||
5. Repeat for each e that is an element of entries,
|
||||
a. If e is not empty and SameValueZero(e, value) is true, then
|
||||
i. Return S.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([ 1 ]);
|
||||
|
||||
assert.sameValue(s.add(1), s, "`s.add(1)` returns `s`");
|
|
@ -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.
|
||||
/*---
|
||||
es6id: 23.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
1. Let S be this value.
|
||||
...
|
||||
8. Return S.
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set();
|
||||
|
||||
assert.sameValue(s.add(1), s, "`s.add(1)` returns `s`");
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call(false, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call(false, 1);
|
||||
});
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call(null, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call(null, 1);
|
||||
});
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call(0, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call(0, 1);
|
||||
});
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call("", 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call("", 1);
|
||||
});
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call(Symbol(), 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call(Symbol(), 1);
|
||||
});
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.add.call(undefined, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.add.call(undefined, 1);
|
||||
});
|
25
test/built-ins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js
vendored
Normal file
25
test/built-ins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js
vendored
Normal file
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
...
|
||||
4. Let entries be the List that is the value of S’s [[SetData]] internal slot.
|
||||
5. Repeat for each e that is an element of entries,
|
||||
a. If e is not empty and SameValueZero(e, value) is true, then
|
||||
i. Return S.
|
||||
6. If value is −0, let value be +0.
|
||||
7. Append value as the last element of entries.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([ 1 ]);
|
||||
|
||||
assert.sameValue(s.size, 1, "The value of `s.size` is `1`");
|
||||
|
||||
s.add(1);
|
||||
|
||||
assert.sameValue(s.size, 1, "The value of `s.size` is `1`");
|
29
test/built-ins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js
vendored
Normal file
29
test/built-ins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js
vendored
Normal file
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
...
|
||||
4. Let entries be the List that is the value of S’s [[SetData]] internal slot.
|
||||
5. Repeat for each e that is an element of entries,
|
||||
a. If e is not empty and SameValueZero(e, value) is true, then
|
||||
i. Return S.
|
||||
6. If value is −0, let value be +0.
|
||||
7. Append value as the last element of entries.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([ -0 ]);
|
||||
|
||||
assert.sameValue(s.size, 1, "The value of `s.size` is `1`");
|
||||
|
||||
s.add(-0);
|
||||
|
||||
assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(-0)`");
|
||||
|
||||
s.add(0);
|
||||
|
||||
assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(0)`");
|
|
@ -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.2.3.1
|
||||
description: >
|
||||
Set.prototype.add ( value )
|
||||
|
||||
...
|
||||
4. Let entries be the List that is the value of S’s [[SetData]] internal slot.
|
||||
5. Repeat for each e that is an element of entries,
|
||||
a. If e is not empty and SameValueZero(e, value) is true, then
|
||||
i. Return S.
|
||||
6. If value is −0, let value be +0.
|
||||
7. Append value as the last element of entries.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set();
|
||||
|
||||
assert.sameValue(s.size, 0, "The value of `s.size` is `0`");
|
||||
|
||||
s.add(1);
|
||||
s.add(1);
|
||||
|
||||
assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(1); s.add(1);`");
|
|
@ -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.2.3.2
|
||||
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");
|
|
@ -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.2.3.2
|
||||
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`");
|
|
@ -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.2.3.2
|
||||
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`");
|
|
@ -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.2.3.2
|
||||
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`");
|
21
test/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js
vendored
Normal file
21
test/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js
vendored
Normal file
|
@ -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.2.3.2
|
||||
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([]);
|
||||
});
|
21
test/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js
vendored
Normal file
21
test/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js
vendored
Normal file
|
@ -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.2.3.2
|
||||
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());
|
||||
});
|
21
test/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js
vendored
Normal file
21
test/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js
vendored
Normal file
|
@ -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.2.3.2
|
||||
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({});
|
||||
});
|
21
test/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js
vendored
Normal file
21
test/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js
vendored
Normal file
|
@ -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.2.3.2
|
||||
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);
|
||||
});
|
21
test/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js
vendored
Normal file
21
test/built-ins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js
vendored
Normal file
|
@ -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.2.3.2
|
||||
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 WeakSet());
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.clear.call(new WeakSet());
|
||||
});
|
|
@ -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.2.3.2
|
||||
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");
|
|
@ -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.2.3.2
|
||||
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");
|
|
@ -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.
|
||||
/*---
|
||||
es6id: 23.2.3.2
|
||||
description: >
|
||||
Set.prototype.clear ( )
|
||||
|
||||
...
|
||||
6. Return undefined.
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set();
|
||||
|
||||
assert.sameValue(s.clear(), undefined, "`s.clear()` returns `undefined`");
|
|
@ -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.2.3.2
|
||||
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);
|
||||
});
|
|
@ -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.2.3.2
|
||||
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);
|
||||
});
|
|
@ -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.2.3.2
|
||||
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);
|
||||
});
|
|
@ -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.2.3.2
|
||||
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("");
|
||||
});
|
|
@ -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.2.3.2
|
||||
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(Symbol());
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.clear.call(Symbol());
|
||||
});
|
|
@ -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.2.3.2
|
||||
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);
|
||||
});
|
16
test/built-ins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js
vendored
Normal file
16
test/built-ins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js
vendored
Normal file
|
@ -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.
|
||||
/*---
|
||||
es6id: 23.2.3.3
|
||||
description: >
|
||||
Set.prototype.constructor
|
||||
|
||||
The initial value of Set.prototype.constructor is the intrinsic object %Set%.
|
||||
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Set.prototype.constructor,
|
||||
Set,
|
||||
"The value of `Set.prototype.constructor` is `Set`"
|
||||
);
|
|
@ -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.
|
||||
/*---
|
||||
es6id: 23.2.1.1
|
||||
description: >
|
||||
Set ( [ iterable ] )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
verifyNotEnumerable(Set.prototype, "constructor");
|
||||
verifyWritable(Set.prototype, "constructor");
|
||||
verifyConfigurable(Set.prototype, "constructor");
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
...
|
||||
4. Let entries be the List that is the value of S’s [[SetData]] internal slot.
|
||||
5. Repeat for each e that is an element of entries,
|
||||
a. If e is not empty and SameValueZero(e, value) is true, then
|
||||
b. Replace the element of entries whose value is e with an element whose value is empty.
|
||||
c. Return true.
|
||||
...
|
||||
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([ 1 ]);
|
||||
|
||||
assert.sameValue(s.size, 1, "The value of `s.size` is `1`");
|
||||
|
||||
var result = s.delete(1);
|
||||
|
||||
assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(1)`");
|
||||
assert.sameValue(result, true, "The result of `s.delete(1)` is `true`");
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
...
|
||||
4. Let entries be the List that is the value of S’s [[SetData]] internal slot.
|
||||
5. Repeat for each e that is an element of entries,
|
||||
a. If e is not empty and SameValueZero(e, value) is true, then
|
||||
b. Replace the element of entries whose value is e with an element whose value is empty.
|
||||
c. Return true.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([ -0 ]);
|
||||
|
||||
assert.sameValue(s.size, 1, "The value of `s.size` is `1`");
|
||||
|
||||
var result = s.delete(+0);
|
||||
|
||||
assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(-0)`");
|
||||
assert.sameValue(result, true, "The result of `s.delete(+0)` is `true`");
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
...
|
||||
4. Let entries be the List that is the value of S’s [[SetData]] internal slot.
|
||||
5. Repeat for each e that is an element of entries,
|
||||
a. If e is not empty and SameValueZero(e, value) is true, then
|
||||
i. Return S.
|
||||
6. If value is −0, let value be +0.
|
||||
7. Append value as the last element of entries.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set();
|
||||
|
||||
assert.sameValue(s.size, 0, "The value of `s.size` is `0`");
|
||||
|
||||
s.add(1);
|
||||
|
||||
assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(1)`");
|
||||
|
||||
var result = s.delete(1);
|
||||
|
||||
assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(1)`");
|
||||
assert.sameValue(result, true, "The result of `s.delete(1)` is `true`");
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Set.prototype.delete,
|
||||
"function",
|
||||
"`typeof Set.prototype.delete` is `'function'`"
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Set.prototype, "delete");
|
||||
verifyWritable(Set.prototype, "delete");
|
||||
verifyConfigurable(Set.prototype, "delete");
|
21
test/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js
vendored
Normal file
21
test/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js
vendored
Normal file
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call([], 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call([], 1);
|
||||
});
|
21
test/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js
vendored
Normal file
21
test/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js
vendored
Normal file
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call(new Map(), 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call(new Map(), 1);
|
||||
});
|
21
test/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js
vendored
Normal file
21
test/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js
vendored
Normal file
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call({}, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call({}, 1);
|
||||
});
|
21
test/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js
vendored
Normal file
21
test/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js
vendored
Normal file
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call(Set.prototype, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call(Set.prototype, 1);
|
||||
});
|
21
test/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js
vendored
Normal file
21
test/built-ins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js
vendored
Normal file
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call(new WeakSet(), 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call(new WeakSet(), 1);
|
||||
});
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Set.prototype.delete.length, 1, "The value of `Set.prototype.delete.length` is `1`");
|
||||
|
||||
verifyNotEnumerable(Set.prototype.delete, "length");
|
||||
verifyNotWritable(Set.prototype.delete, "length");
|
||||
verifyConfigurable(Set.prototype.delete, "length");
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Set.prototype.delete.name, "delete", "The value of `Set.prototype.delete.name` is `'delete'`");
|
||||
|
||||
verifyNotEnumerable(Set.prototype.delete, "name");
|
||||
verifyNotWritable(Set.prototype.delete, "name");
|
||||
verifyConfigurable(Set.prototype.delete, "name");
|
|
@ -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.
|
||||
/*---
|
||||
es6id: 23.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
...
|
||||
6. Return false.
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set();
|
||||
|
||||
assert.sameValue(s.delete(1), false, "`s.delete(1)` returns `false`");
|
22
test/built-ins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js
vendored
Normal file
22
test/built-ins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js
vendored
Normal file
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
...
|
||||
4. Let entries be the List that is the value of S’s [[SetData]] internal slot.
|
||||
5. Repeat for each e that is an element of entries,
|
||||
a. If e is not empty and SameValueZero(e, value) is true, then
|
||||
b. Replace the element of entries whose value is e with an element whose value is empty.
|
||||
c. Return true.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set();
|
||||
|
||||
s.add(1);
|
||||
|
||||
assert.sameValue(s.delete(1), true, "`s.delete(1)` returns `true`");
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call(false, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call(false, 1);
|
||||
});
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call(null, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call(null, 1);
|
||||
});
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call(0, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call(0, 1);
|
||||
});
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call("", 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call("", 1);
|
||||
});
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call(Symbol(), 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call(Symbol(), 1);
|
||||
});
|
|
@ -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.2.3.4
|
||||
description: >
|
||||
Set.prototype.delete ( value )
|
||||
|
||||
1. Let S be the this value.
|
||||
2. If Type(S) is not Object, throw a TypeError exception.
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.delete.call(undefined, 1);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.delete.call(undefined, 1);
|
||||
});
|
|
@ -1,13 +0,0 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
If the context does not have a [[SetData]] internal slot, throw a
|
||||
TypeError exception as per 23.2.5.1.
|
||||
es6id: 23.2.3.5
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call({});
|
||||
});
|
27
test/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js
vendored
Normal file
27
test/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js
vendored
Normal file
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
...
|
||||
2. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call([]);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call([]);
|
||||
});
|
26
test/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js
vendored
Normal file
26
test/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js
vendored
Normal file
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
...
|
||||
2. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call(new Map());
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call(new Map());
|
||||
});
|
26
test/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js
vendored
Normal file
26
test/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js
vendored
Normal file
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
...
|
||||
2. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call({});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call({});
|
||||
});
|
26
test/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js
vendored
Normal file
26
test/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js
vendored
Normal file
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
...
|
||||
2. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call(Set.prototype);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call(Set.prototype);
|
||||
});
|
26
test/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js
vendored
Normal file
26
test/built-ins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js
vendored
Normal file
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
...
|
||||
2. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call(new WeakSet());
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call(new WeakSet());
|
||||
});
|
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Set.prototype.entries,
|
||||
"function",
|
||||
"`typeof Set.prototype.entries` is `'function'`"
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Set.prototype, "entries");
|
||||
verifyWritable(Set.prototype, "entries");
|
||||
verifyConfigurable(Set.prototype, "entries");
|
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Set.prototype.entries.length, 0, "The value of `Set.prototype.entries.length` is `0`");
|
||||
|
||||
verifyNotEnumerable(Set.prototype.entries, "length");
|
||||
verifyNotWritable(Set.prototype.entries, "length");
|
||||
verifyConfigurable(Set.prototype.entries, "length");
|
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Set.prototype.entries.name, "entries", "The value of `Set.prototype.entries.name` is `'entries'`");
|
||||
|
||||
verifyNotEnumerable(Set.prototype.entries, "name");
|
||||
verifyNotWritable(Set.prototype.entries, "name");
|
||||
verifyConfigurable(Set.prototype.entries, "name");
|
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
...
|
||||
7. Return iterator.
|
||||
|
||||
|
||||
---*/
|
||||
|
||||
var set = new Set();
|
||||
var iterator = set.entries();
|
||||
var result = iterator.next();
|
||||
|
||||
assert.sameValue(result.value, undefined, "The value of `result.value` is `undefined`");
|
||||
assert.sameValue(result.done, true, "The value of `result.done` is `true`");
|
|
@ -1,12 +1,21 @@
|
|||
// Copyright (C) 2014 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
The method should return a valid iterator with the context as the
|
||||
IteratedObject.
|
||||
es6id: 23.2.3.5
|
||||
---*/
|
||||
es6id: 23.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
...
|
||||
7. Return iterator.
|
||||
|
||||
|
||||
---*/
|
||||
|
||||
var set = new Set();
|
||||
set.add(1);
|
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
1. If Type(set) is not Object, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call(false);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call(false);
|
||||
});
|
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
1. If Type(set) is not Object, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call(null);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call(null);
|
||||
});
|
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
1. If Type(set) is not Object, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call(0);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call(0);
|
||||
});
|
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
1. If Type(set) is not Object, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call("");
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call("");
|
||||
});
|
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
1. If Type(set) is not Object, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call(Symbol());
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call(Symbol());
|
||||
});
|
|
@ -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.2.3.5
|
||||
description: >
|
||||
Set.prototype.entries ( )
|
||||
|
||||
...
|
||||
2. Return CreateSetIterator(S, "key+value").
|
||||
|
||||
|
||||
23.2.5.1 CreateSetIterator Abstract Operation
|
||||
|
||||
1. If Type(set) is not Object, throw a TypeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.entries.call(undefined);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.entries.call(undefined);
|
||||
});
|
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
4. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||
...
|
||||
|
||||
Passing `false` as callback
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([1]);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.forEach(false);
|
||||
});
|
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
4. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||
...
|
||||
|
||||
Passing `null` as callback
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([1]);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.forEach(null);
|
||||
});
|
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
4. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||
...
|
||||
|
||||
Passing `number` as callback
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([1]);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.forEach(0);
|
||||
});
|
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
4. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||
...
|
||||
|
||||
Passing `string` as callback
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([1]);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.forEach("");
|
||||
});
|
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
4. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||
...
|
||||
|
||||
Passing `symbol` as callback
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([1]);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.forEach(Symbol());
|
||||
});
|
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
4. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||
...
|
||||
|
||||
Passing `undefined` as callback
|
||||
|
||||
---*/
|
||||
|
||||
var s = new Set([1]);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
s.forEach(undefined);
|
||||
});
|
21
test/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js
vendored
Normal file
21
test/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js
vendored
Normal file
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.forEach.call([], function() {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.forEach.call([], function() {});
|
||||
});
|
21
test/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js
vendored
Normal file
21
test/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js
vendored
Normal file
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.forEach.call(new Map(), function() {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.forEach.call(new Map(), function() {});
|
||||
});
|
21
test/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js
vendored
Normal file
21
test/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js
vendored
Normal file
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.forEach.call({}, function() {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.forEach.call({}, function() {});
|
||||
});
|
21
test/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js
vendored
Normal file
21
test/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js
vendored
Normal file
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.forEach.call(Set.prototype, function() {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.forEach.call(Set.prototype, function() {});
|
||||
});
|
21
test/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js
vendored
Normal file
21
test/built-ins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js
vendored
Normal file
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
3. If S does not have a [[SetData]] internal slot, throw a TypeError exception.
|
||||
...
|
||||
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Set.prototype.forEach.call(new WeakSet(), function() {});
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var s = new Set();
|
||||
s.forEach.call(new WeakSet(), function() {});
|
||||
});
|
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
17 ECMAScript Standard Built-in Objects
|
||||
|
||||
includes: [propertyHelper.js]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Set.prototype.forEach,
|
||||
"function",
|
||||
"`typeof Set.prototype.forEach` is `'function'`"
|
||||
);
|
||||
|
||||
verifyNotEnumerable(Set.prototype, "forEach");
|
||||
verifyWritable(Set.prototype, "forEach");
|
||||
verifyConfigurable(Set.prototype, "forEach");
|
|
@ -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.2.3.6
|
||||
description: >
|
||||
Set.prototype.forEach ( callbackfn [ , thisArg ] )
|
||||
|
||||
...
|
||||
7. Repeat for each e that is an element of entries, in original insertion order
|
||||
a. If e is not empty, then
|
||||
i. Let funcResult be Call(callbackfn, T, «e, e, S»).
|
||||
ii. ReturnIfAbrupt(funcResult).
|
||||
...
|
||||
---*/
|
||||
|
||||
var s = new Set();
|
||||
var expects = [1, 2, 3];
|
||||
|
||||
s.add(1).add(2).add(3);
|
||||
|
||||
s.forEach(function(value, entry, set) {
|
||||
var expect = expects.shift();
|
||||
|
||||
assert.sameValue(value, expect);
|
||||
assert.sameValue(entry, expect);
|
||||
assert.sameValue(set, s);
|
||||
});
|
||||
|
||||
assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`");
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue