Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Map/iterator-items-are-not-object.js

raw
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.1.1.1
5 description: >
6 Throws a TypeError if iterable items are not Objects.
7 info: |
8 Map ( [ iterable ] )
9
10 ...
11 9. Repeat
12 ...
13 d. Let nextItem be IteratorValue(next).
14 e. ReturnIfAbrupt(nextItem).
15 f. If Type(nextItem) is not Object,
16 i. Let error be Completion{[[type]]: throw, [[value]]: a newly created
17 TypeError object, [[target]]:empty}.
18 ii. Return IteratorClose(iter, error).
19 features: [Symbol]
20 ---*/
21
22 assert.throws(TypeError, function() {
23 new Map([1]);
24 });
25
26 assert.throws(TypeError, function() {
27 new Map(['']);
28 });
29
30 assert.throws(TypeError, function() {
31 new Map([true]);
32 });
33
34 assert.throws(TypeError, function() {
35 new Map([null]);
36 });
37
38 assert.throws(TypeError, function() {
39 new Map([Symbol('a')]);
40 });
41
42 assert.throws(TypeError, function() {
43 new Map([undefined]);
44 });
45
46 assert.throws(TypeError, function() {
47 new Map([
48 ['a', 1],
49 2
50 ]);
51 });