1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/collections/Map-values-2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,18 @@ 1.4 +// map.keys() and map.values() return iterators over the key or the value, 1.5 +// respectively, of each key-value pair in the map. 1.6 + 1.7 +load(libdir + "iteration.js"); 1.8 + 1.9 +var data = [["one", 1], ["two", 2], ["three", 3], ["four", 4]]; 1.10 +var m = Map(data); 1.11 + 1.12 +var ki = m.keys(); 1.13 +assertIteratorNext(ki, "one"); 1.14 +assertIteratorNext(ki, "two"); 1.15 +assertIteratorNext(ki, "three"); 1.16 +assertIteratorNext(ki, "four"); 1.17 +assertIteratorDone(ki, undefined); 1.18 + 1.19 +assertEq([k for (k of m.keys())].toSource(), ["one", "two", "three", "four"].toSource()); 1.20 +assertEq([k for (k of m.values())].toSource(), [1, 2, 3, 4].toSource()); 1.21 +assertEq([k for (k of m.entries())].toSource(), data.toSource());