michael@0: // map.keys() and map.values() return iterators over the key or the value, michael@0: // respectively, of each key-value pair in the map. michael@0: michael@0: load(libdir + "iteration.js"); michael@0: michael@0: var data = [["one", 1], ["two", 2], ["three", 3], ["four", 4]]; michael@0: var m = Map(data); michael@0: michael@0: var ki = m.keys(); michael@0: assertIteratorNext(ki, "one"); michael@0: assertIteratorNext(ki, "two"); michael@0: assertIteratorNext(ki, "three"); michael@0: assertIteratorNext(ki, "four"); michael@0: assertIteratorDone(ki, undefined); michael@0: michael@0: assertEq([k for (k of m.keys())].toSource(), ["one", "two", "three", "four"].toSource()); michael@0: assertEq([k for (k of m.values())].toSource(), [1, 2, 3, 4].toSource()); michael@0: assertEq([k for (k of m.entries())].toSource(), data.toSource());