Add missed changes for Symbols as WeakMap keys proposal.

Co-authored-by: Rick Waldron <waldron.rick@gmail.com>
This commit is contained in:
Ms2ger 2022-11-08 11:20:13 +01:00 committed by Philip Chimento
parent f6c48f333e
commit 0593463817
3 changed files with 41 additions and 1 deletions

View File

@ -68,7 +68,7 @@ assert.throws(TypeError, function() {
});
assert.sameValue(count, 5);
nextItem = Symbol('a');
nextItem = Symbol.for('a');
assert.throws(TypeError, function() {
new WeakMap(iterable);
});

View File

@ -0,0 +1,18 @@
// Copyright (C) 2022 Igalia S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-weakset.prototype.add
description: Returns `this` after adding a new value.
info: |
WeakSet.prototype.add ( value )
1. Let S be the this value.
...
7. Return S.
features: [Symbol, WeakSet, symbols-as-weakmap-keys]
---*/
var s = new WeakSet();
assert.sameValue(s.add(Symbol('description')), s, '`s.add(Symbol("description"))` returns `s`');

View File

@ -0,0 +1,22 @@
// Copyright (C) 2022 Igalia S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-weakset.prototype.add
description: Returns `this` when new value is duplicate.
info: |
WeakSet.prototype.add ( value )
1. Let S be the this value.
...
5. 5. For each element e of entries, do
a. If e is not empty and SameValue(e, value) is true, then
i. Return S.
...
features: [Symbol, WeakSet, symbols-as-weakmap-keys]
---*/
var foo = Symbol('description');
var s = new WeakSet([foo]);
assert.sameValue(s.add(foo), s, '`s.add(foo)` returns `s`');