michael@0: // Superficial tests for iterators created by Array.prototype.iterator michael@0: michael@0: load(libdir + "iteration.js"); michael@0: michael@0: var proto = Object.getPrototypeOf([][std_iterator]()); michael@0: assertEq(Object.getPrototypeOf(proto), Iterator.prototype); michael@0: proto = Object.getPrototypeOf([].keys()); michael@0: assertEq(Object.getPrototypeOf(proto), Iterator.prototype); michael@0: proto = Object.getPrototypeOf([].entries()); michael@0: assertEq(Object.getPrototypeOf(proto), Iterator.prototype); michael@0: michael@0: function check(it) { michael@0: assertEq(typeof it, 'object'); michael@0: assertEq(Object.getPrototypeOf(it), proto); michael@0: assertEq(Object.getOwnPropertyNames(it).length, 0); michael@0: assertEq(it[std_iterator](), it); michael@0: michael@0: // for-in enumerates the iterator's properties. michael@0: it.x = 0; michael@0: var s = ''; michael@0: for (var p in it) michael@0: s += p + '.'; michael@0: assertEq(s, 'x.'); michael@0: } michael@0: michael@0: check([][std_iterator]()); michael@0: check(Array.prototype[std_iterator].call({})); michael@0: check([].keys()); michael@0: check(Array.prototype.keys.call({})); michael@0: check([].entries()); michael@0: check(Array.prototype.entries.call({}));