js/src/jit-test/tests/collections/Set-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/Set-iterator-proxies-2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,20 @@
     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 + "iteration.js");
     1.8 +
     1.9 +var g = newGlobal();
    1.10 +
    1.11 +var iterator_fn = Set.prototype[std_iterator];
    1.12 +assertThrowsInstanceOf(function () { iterator_fn.call({}); }, TypeError);
    1.13 +assertThrowsInstanceOf(function () { iterator_fn.call(Map()); }, TypeError);
    1.14 +var setw = g.eval("Set(['x', 'y'])");
    1.15 +assertIteratorNext(iterator_fn.call(setw), "x");
    1.16 +
    1.17 +var next_fn = Set()[std_iterator]().next;
    1.18 +assertThrowsInstanceOf(function () { next_fn.call({}); }, TypeError);
    1.19 +assertThrowsInstanceOf(function () { next_fn.call(Map()[std_iterator]()); }, TypeError);
    1.20 +var iterw = setw[std_iterator]();
    1.21 +assertIteratorResult(next_fn.call(iterw), "x", false);
    1.22 +assertIteratorResult(next_fn.call(iterw), "y", false);
    1.23 +assertIteratorResult(next_fn.call(iterw), undefined, true);

mercurial