| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
es6id: 23.3.1.1 |
| 5 |
esid: sec-weakmap-iterable |
| 6 |
description: > |
| 7 |
Throws a TypeError if iterable itens are not Objects. |
| 8 |
info: | |
| 9 |
WeakMap ( [ iterable ] ) |
| 10 |
|
| 11 |
... |
| 12 |
9. Repeat |
| 13 |
... |
| 14 |
d. Let nextItem be IteratorValue(next). |
| 15 |
e. ReturnIfAbrupt(nextItem). |
| 16 |
f. If Type(nextItem) is not Object, |
| 17 |
i. Let error be Completion{[[type]]: throw, [[value]]: a newly created |
| 18 |
TypeError object, [[target]]:empty}. |
| 19 |
ii. Return IteratorClose(iter, error). |
| 20 |
features: [Symbol] |
| 21 |
---*/ |
| 22 |
|
| 23 |
assert.throws(TypeError, function() { |
| 24 |
new WeakMap([1, 1]); |
| 25 |
}); |
| 26 |
|
| 27 |
assert.throws(TypeError, function() { |
| 28 |
new WeakMap(['', 1]); |
| 29 |
}); |
| 30 |
|
| 31 |
assert.throws(TypeError, function() { |
| 32 |
new WeakMap([true, 1]); |
| 33 |
}); |
| 34 |
|
| 35 |
assert.throws(TypeError, function() { |
| 36 |
new WeakMap([null, 1]); |
| 37 |
}); |
| 38 |
|
| 39 |
assert.throws(TypeError, function() { |
| 40 |
new WeakMap([Symbol('a'), 1]); |
| 41 |
}); |
| 42 |
|
| 43 |
assert.throws(TypeError, function() { |
| 44 |
new WeakMap([undefined, 1]); |
| 45 |
}); |
| 46 |
|
| 47 |
assert.throws(TypeError, function() { |
| 48 |
new WeakMap([ |
| 49 |
['a', 1], 2 |
| 50 |
]); |
| 51 |
}); |