Skip to content

Commit

Permalink
Test: forEach will throw in near-infinite iteration.
Browse files Browse the repository at this point in the history
Improves test coverage
  • Loading branch information
leebyron committed Feb 21, 2018
1 parent 3474149 commit 4b54483
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test.js
Expand Up @@ -663,6 +663,22 @@ test('forEach iterates over Array-like with early break', () => {
])
})

function* infiniteIterator() {
while (true) {
yield true
}
}

test('forEach throws when iterating over infinite iterator', () => {
var caughtError
try {
forEach(infiniteIterator(), () => {})
} catch (e) {
caughtError = e
}
assert.equal(caughtError && caughtError.message, 'Near-infinite iteration.')
})

// createIterator

var createIterator = require('./').createIterator
Expand Down

0 comments on commit 4b54483

Please sign in to comment.