tor-browser

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

iterable-calls-set.js (956B)


      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  new Map calls `set` for each item on the iterable argument in order.
      7 info: |
      8  Map ( [ iterable ] )
      9 
     10  ...
     11  9. Repeat
     12    ...
     13    k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»).
     14  ...
     15 includes: [compareArray.js]
     16 ---*/
     17 
     18 var mapSet = Map.prototype.set;
     19 var counter = 0;
     20 
     21 var iterable = [
     22  ["foo", 1],
     23  ["bar", 2]
     24 ];
     25 var results = [];
     26 var _this = [];
     27 
     28 Map.prototype.set = function(k, v) {
     29  counter++;
     30  results.push([k, v]);
     31  _this.push(this);
     32  mapSet.call(this, k, v);
     33 };
     34 
     35 var map = new Map(iterable);
     36 
     37 assert.sameValue(counter, 2, "`Map.prototype.set` called twice.");
     38 
     39 assert.compareArray(results[0], iterable[0]);
     40 assert.compareArray(results[1], iterable[1]);
     41 assert.sameValue(_this[0], map);
     42 assert.sameValue(_this[1], map);
     43 
     44 reportCompare(0, 0);