js/src/jit-test/tests/collections/Map-iterator-proxies-2.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/collections/Map-iterator-proxies-2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,21 @@
     1.4 +// map.iterator() and iter.next() are non-generic but work on cross-compartment wrappers.
     1.5 +
     1.6 +load(libdir + "asserts.js");
     1.7 +load(libdir + "eqArrayHelper.js");
     1.8 +load(libdir + "iteration.js");
     1.9 +
    1.10 +var g = newGlobal();
    1.11 +
    1.12 +var iterator_fn = Map.prototype[std_iterator];
    1.13 +assertThrowsInstanceOf(function () { iterator_fn.call({}); }, TypeError);
    1.14 +assertThrowsInstanceOf(function () { iterator_fn.call(Set()); }, TypeError);
    1.15 +var mapw = g.eval("Map([['x', 1], ['y', 2]])");
    1.16 +assertEqArray(iterator_fn.call(mapw).next().value, ["x", 1]);
    1.17 +
    1.18 +var next_fn = Map()[std_iterator]().next;
    1.19 +assertThrowsInstanceOf(function () { next_fn.call({}); }, TypeError);
    1.20 +assertThrowsInstanceOf(function () { next_fn.call(Set()[std_iterator]()); }, TypeError);
    1.21 +var iterw = mapw[std_iterator]();
    1.22 +assertEqArray(next_fn.call(iterw).value, ["x", 1]);
    1.23 +assertEqArray(next_fn.call(iterw).value, ["y", 2]);
    1.24 +assertEq(next_fn.call(iterw).done, true);

mercurial