From 00d89ff82864180d618ae568e3599109845babd9 Mon Sep 17 00:00:00 2001 From: "Claudia[bot]" <4437565+Claudia[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 08:09:59 +0200 Subject: [PATCH] test(single-line): make the linearity check fail on time, not on the result The input ended on a whitespace run, so the old regex returned a different string and the test failed on the result before it reached the time bound. Keep the run inside a line ('ab\nc'): the old regex and the split now return the same 'ab c', and only the elapsed time tells them apart (about 1.8 s against well under a millisecond). Co-Authored-By: Christian Haberl <116439789+christianhaberl@users.noreply.github.com> Co-Authored-By: Claude --- test/unattended-single-line-prompt.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/unattended-single-line-prompt.test.ts b/test/unattended-single-line-prompt.test.ts index aa834174..a23fe0a1 100644 --- a/test/unattended-single-line-prompt.test.ts +++ b/test/unattended-single-line-prompt.test.ts @@ -43,12 +43,13 @@ describe('toSingleLine', () => { }); it('stays linear on a long whitespace run', () => { - // A regex that folds the whitespace around each break backtracks over every - // start position in the run: 50,000 spaces took well over a second that way. - // The split takes well under a millisecond, so the bound leaves room either side. + // The run sits inside a line, so the result is the same either way; only the time + // differs. A regex that folds the whitespace around each break retries the run from + // every start position: 50,000 spaces took over a second that way. The split takes + // well under a millisecond, so the bound leaves room either side. const run = ' '.repeat(50_000); const started = performance.now(); - const joined = toSingleLine(`a${run}b\nc${run}`); + const joined = toSingleLine(`a${run}b\nc`); const elapsed = performance.now() - started; expect(joined).toBe(`a${run}b c`); expect(elapsed).toBeLessThan(250);