diff --git a/lib/runner/cursor.js b/lib/runner/cursor.js index 34d01a333..11d3bd5c5 100644 --- a/lib/runner/cursor.js +++ b/lib/runner/cursor.js @@ -236,9 +236,9 @@ _.assign(Cursor.prototype, { if (iteration >= this.cycles) { return _.assign(base, { - position: this.length - 1, - iteration: iteration - 1, - eof: true + position: coords.position, + iteration: coords.iteration, + eof: this.partitionCycles > 0 }); } diff --git a/test/unit/runner-cursor.test.js b/test/unit/runner-cursor.test.js index 2ad6e99e9..ab2e703e0 100644 --- a/test/unit/runner-cursor.test.js +++ b/test/unit/runner-cursor.test.js @@ -113,6 +113,20 @@ describe('cursor', function () { done(); }); }); + it('should have whatnext() match next() behavior at final position', function () { + var Cursor = require('../../lib/runner/cursor'), + cursor = new Cursor(2, 1, 1, 0), // length=2, at last position + predicted = cursor.whatnext(cursor.current()); + + cursor.next(function () { + var actual = cursor.current(); + + expect(predicted.eof).to.equal(actual.eof); + expect(predicted.position).to.equal(actual.position); + expect(predicted.iteration).to.equal(actual.iteration); + }); + }); + describe('partition support', function () { it('should accept partitionIndex and partitionCycles parameters', function () {