iterator-proto-1.js (642B)
1 // All iterators of the same collection type share their immediate prototype. 2 // Those prototype objects in turn inherit directly from %IteratorPrototype%. 3 4 load(libdir + "iteration.js"); 5 6 // Get %IteratorPrototype%. 7 var iterProto = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())); 8 9 function test(obj0, obj1) { 10 var iter0 = obj0[Symbol.iterator](), iter1 = obj1[Symbol.iterator](); 11 var proto = Object.getPrototypeOf(iter0); 12 assertEq(Object.getPrototypeOf(iter1), proto); 13 assertEq(Object.getPrototypeOf(proto), iterProto); 14 } 15 16 test([], [1]); 17 test(new Map(), new Map([[1, 1]])); 18 test(new Set(), new Set([1]));