| 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 |
A Map constructed without a iterable argument does not call set. |
| 7 |
info: | |
| 8 |
Map ( [ iterable ] ) |
| 9 |
|
| 10 |
When the Map function is called with optional argument the following steps are |
| 11 |
taken: |
| 12 |
|
| 13 |
... |
| 14 |
5. If iterable is not present, let iterable be undefined. |
| 15 |
6. If iterable is either undefined or null, let iter be undefined. |
| 16 |
7. Else, |
| 17 |
a. Let adder be Get(map, "set"). |
| 18 |
b. ReturnIfAbrupt(adder). |
| 19 |
c. If IsCallable(adder) is false, throw a TypeError exception. |
| 20 |
d. Let iter be GetIterator(iterable). |
| 21 |
e. ReturnIfAbrupt(iter). |
| 22 |
8. If iter is undefined, return map. |
| 23 |
---*/ |
| 24 |
|
| 25 |
var set = Map.prototype.set; |
| 26 |
var counter = 0; |
| 27 |
|
| 28 |
Map.prototype.set = function(value) { |
| 29 |
counter++; |
| 30 |
set.call(this, value); |
| 31 |
}; |
| 32 |
|
| 33 |
new Map(); |
| 34 |
|
| 35 |
assert.sameValue(counter, 0, '`Map.prototype.set` was not called.'); |