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