blob: d92f3a283bf2783a4f46f1ededa6eeaa0ad9cd4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-weakset.prototype.add
description: Throws TypeError if value cannot be held weakly.
info: |
WeakSet.prototype.add ( _value_ )
3. If CanBeHeldWeakly(_value_) is *false*, throw a *TypeError* exception.
features: [Symbol, WeakSet]
---*/
var s = new WeakSet();
assert.throws(TypeError, function() {
s.add(1);
});
assert.throws(TypeError, function() {
s.add(false);
});
assert.throws(TypeError, function() {
s.add();
});
assert.throws(TypeError, function() {
s.add('string');
});
assert.throws(TypeError, function() {
s.add(null);
});
assert.throws(TypeError, function() {
s.add(Symbol.for('registered symbol'));
}, 'Registered symbol not allowed as WeakSet value');
reportCompare(0, 0);
|