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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// |reftest| skip-if(!this.hasOwnProperty('WeakRef')) -- WeakRef is not enabled unconditionally
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-weak-ref-target
description: >
Throws a TypeError if target cannot be held weakly
info: |
WeakRef ( _target_ )
2. If CanBeHeldWeakly(_target_) is *false*, throw a *TypeError* exception.
features: [WeakRef]
---*/
assert.sameValue(
typeof WeakRef, 'function',
'typeof WeakRef is function'
);
assert.throws(TypeError, function() {
new WeakRef();
}, 'implicit undefined');
assert.throws(TypeError, function() {
new WeakRef(undefined);
}, 'explicit undefined');
assert.throws(TypeError, function() {
new WeakRef(null);
}, 'null');
assert.throws(TypeError, function() {
new WeakRef(1);
}, 'number');
assert.throws(TypeError, function() {
new WeakRef('Object');
}, 'string');
var s = Symbol.for('registered symbol');
assert.throws(TypeError, function() {
new WeakRef(s);
}, 'registered symbol');
assert.throws(TypeError, function() {
new WeakRef(true);
}, 'Boolean, true');
assert.throws(TypeError, function() {
new WeakRef(false);
}, 'Boolean, false');
reportCompare(0, 0);
|