summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/collections/iterator-proto-1.js
blob: c9827a5746d8dbd52980ed6708a7b9a434dd84c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// All iterators of the same collection type share their immediate prototype.
// Those prototype objects in turn inherit directly from %IteratorPrototype%.

load(libdir + "iteration.js");

// Get %IteratorPrototype%.
var iterProto = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));

function test(obj0, obj1) {
    var iter0 = obj0[Symbol.iterator](), iter1 = obj1[Symbol.iterator]();
    var proto = Object.getPrototypeOf(iter0);
    assertEq(Object.getPrototypeOf(iter1), proto);
    assertEq(Object.getPrototypeOf(proto), iterProto);
}

test([], [1]);
test(new Map(), new Map([[1, 1]]));
test(new Set(), new Set([1]));