tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

iterator-items-are-not-object.js (1085B)


      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 esid: sec-map-iterable
      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 });
     52 
     53 reportCompare(0, 0);