From 8deea2780b0e75b209400f23653510dc2b8e7ab4 Mon Sep 17 00:00:00 2001 From: Aggarwalmansi Date: Fri, 26 Dec 2025 22:37:46 +0530 Subject: [PATCH 1/2] fix(cursor): align whatnext EOF behavior with next --- lib/runner/cursor.js | 8 +++++--- test/unit/runner-cursor.test.js | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/runner/cursor.js b/lib/runner/cursor.js index 34d01a333..1e3f7a4a5 100644 --- a/lib/runner/cursor.js +++ b/lib/runner/cursor.js @@ -236,9 +236,11 @@ _.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..9c82b3113 100644 --- a/test/unit/runner-cursor.test.js +++ b/test/unit/runner-cursor.test.js @@ -113,6 +113,21 @@ 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 + + var 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 () { From 5fbf158f089bfe2119c6325be6c9235820464012 Mon Sep 17 00:00:00 2001 From: Aggarwalmansi Date: Fri, 26 Dec 2025 23:35:27 +0530 Subject: [PATCH 2/2] fix(cursor): align whatnext() behavior with next() at final iteration --- lib/runner/cursor.js | 2 -- test/unit/runner-cursor.test.js | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/runner/cursor.js b/lib/runner/cursor.js index 1e3f7a4a5..11d3bd5c5 100644 --- a/lib/runner/cursor.js +++ b/lib/runner/cursor.js @@ -239,8 +239,6 @@ _.assign(Cursor.prototype, { 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 9c82b3113..ab2e703e0 100644 --- a/test/unit/runner-cursor.test.js +++ b/test/unit/runner-cursor.test.js @@ -115,9 +115,8 @@ describe('cursor', function () { }); 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 - - var predicted = cursor.whatnext(cursor.current()); + cursor = new Cursor(2, 1, 1, 0), // length=2, at last position + predicted = cursor.whatnext(cursor.current()); cursor.next(function () { var actual = cursor.current();