michael@0: // This was the actual bug michael@0: assertRaises(StopIteration, function() { michael@0: Iterator.prototype.next(); michael@0: Iterator.prototype.next(); michael@0: }); michael@0: michael@0: // The error should have triggered here, but was masked by a latent bug michael@0: assertRaises(StopIteration, function() { michael@0: Iterator.prototype.next(); michael@0: }); michael@0: michael@0: // Found by fuzzing michael@0: assertRaises(StopIteration, function() { michael@0: (new Iterator({})).__proto__.next(); michael@0: }); michael@0: michael@0: michael@0: function assertRaises(exc, callback) { michael@0: var caught = false; michael@0: try { michael@0: callback(); michael@0: } catch (e) { michael@0: assertEq(e instanceof StopIteration, true); michael@0: caught = true; michael@0: } michael@0: assertEq(caught, true); michael@0: }