michael@0: // Deleting the .next method of an iterator in the middle of a for-of loop michael@0: // causes a TypeError at the next iteration. michael@0: michael@0: load(libdir + "asserts.js"); michael@0: load(libdir + "iteration.js"); michael@0: michael@0: var iterProto = Object.getPrototypeOf([][std_iterator]()); michael@0: var s = ''; michael@0: assertThrowsInstanceOf(function () { michael@0: for (var v of ['duck', 'duck', 'duck', 'goose', 'FAIL']) { michael@0: s += v; michael@0: if (v === 'goose') michael@0: delete iterProto.next; michael@0: s += '.'; michael@0: } michael@0: }, TypeError); michael@0: assertEq(s, 'duck.duck.duck.goose.');