blob: 02eada9cc1ae19d7e24184cba013a9698a81ffc9 [file] [log] [blame]
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var map = new Map([[1,2], [2,3], [3,4]]);
var iterator = map.keys();
assertEquals([1,2,3], [...map.keys()]);
assertEquals([1,2,3], [...iterator]);
assertEquals([], [...iterator]);
iterator = map.values();
assertEquals([2,3,4], [...iterator]);
assertEquals([], [...iterator]);
iterator = map.keys();
iterator.next();
assertEquals([2,3], [...iterator]);
assertEquals([], [...iterator]);
iterator = map.values();
var iterator2 = map.values();
map.delete(1);
assertEquals([3,4], [...iterator]);
assertEquals([], [...iterator]);
map.set(1,5);
assertEquals([3,4,5], [...iterator2]);
assertEquals([], [...iterator2]);
iterator = map.keys();
map.set(4,6);
assertEquals([2,3,1,4], [...iterator]);
assertEquals([], [...iterator]);