|
1 // map.iterator() and iter.next() are non-generic but work on cross-compartment wrappers. |
|
2 |
|
3 load(libdir + "asserts.js"); |
|
4 load(libdir + "eqArrayHelper.js"); |
|
5 load(libdir + "iteration.js"); |
|
6 |
|
7 var g = newGlobal(); |
|
8 |
|
9 var iterator_fn = Map.prototype[std_iterator]; |
|
10 assertThrowsInstanceOf(function () { iterator_fn.call({}); }, TypeError); |
|
11 assertThrowsInstanceOf(function () { iterator_fn.call(Set()); }, TypeError); |
|
12 var mapw = g.eval("Map([['x', 1], ['y', 2]])"); |
|
13 assertEqArray(iterator_fn.call(mapw).next().value, ["x", 1]); |
|
14 |
|
15 var next_fn = Map()[std_iterator]().next; |
|
16 assertThrowsInstanceOf(function () { next_fn.call({}); }, TypeError); |
|
17 assertThrowsInstanceOf(function () { next_fn.call(Set()[std_iterator]()); }, TypeError); |
|
18 var iterw = mapw[std_iterator](); |
|
19 assertEqArray(next_fn.call(iterw).value, ["x", 1]); |
|
20 assertEqArray(next_fn.call(iterw).value, ["y", 2]); |
|
21 assertEq(next_fn.call(iterw).done, true); |