summaryrefslogtreecommitdiff
path: root/test/built-ins/Map/prototype/delete/does-not-break-iterators.js
blob: 1a788fdc0ce6397e4b06d77b907a5b1e057d17a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 23.1.3.3
description: >
  Deleting an entry does not break a [[MapData]] List.
info: |
  Map.prototype.delete ( key )

  4. Let entries be the List that is the value of M’s [[MapData]] internal slot.
  5. Repeat for each Record {[[key]], [[value]]} p that is an element of entries,
    a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, then
      i. Set p.[[key]] to empty.
      ii. Set p.[[value]] to empty.
      iii. Return true.
  ...
---*/

var m = new Map([
  ['a', 1],
  ['b', 2],
  ['c', 3]
]);
var e = m.entries();

e.next();
m.delete('b');

var n = e.next();

assert.sameValue(n.value[0], 'c');
assert.sameValue(n.value[1], 3);

n = e.next();
assert.sameValue(n.value, undefined);
assert.sameValue(n.done, true);