diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 20:56:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 20:56:19 +0000 |
commit | 0b6210cd37b68b94252cb798598b12974a20e1c1 (patch) | |
tree | e371686554a877842d95aa94f100bee552ff2a8e /llparse/test/resumption-test.ts | |
parent | Initial commit. (diff) | |
download | node-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.tar.xz node-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.zip |
Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3.upstream/5.28.2+dfsg1+_cs23.11.12.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'llparse/test/resumption-test.ts')
-rw-r--r-- | llparse/test/resumption-test.ts | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/llparse/test/resumption-test.ts b/llparse/test/resumption-test.ts new file mode 100644 index 0000000..438b7fd --- /dev/null +++ b/llparse/test/resumption-test.ts @@ -0,0 +1,55 @@ +import * as assert from 'assert'; + +import { LLParse } from '../src/api'; + +import { build, ERROR_PAUSE, printMatch, printOff } from './fixtures'; + +describe('llparse/resumption', () => { + let p: LLParse; + + beforeEach(() => { + p = new LLParse(); + }); + + it('should resume after span end pause', async () => { + const start = p.node('start'); + const a = p.node('a'); + const span = p.span(p.code.span('llparse__pause_once')); + + start + .peek('a', span.start(a)) + .skipTo(start); + + a + .match('a', a) + .otherwise(span.end(start)); + + const binary = await build(p, start, 'resume-span'); + + await binary.check('baaab', + new RegExp( + '^(' + + 'off=\\d+ pause\\noff=1 len=3 span\\[pause\\]="aaa"' + + '|' + + 'off=1 len=3 span\\[pause\\]="aaa"\noff=4 pause' + + ')\\n$' + , 'g')); + }); + + it('should resume after `pause` node', async () => { + const start = p.node('start'); + const pause = p.pause(ERROR_PAUSE, 'paused'); + + start + .match('p', pause) + .skipTo(start); + + pause + .otherwise(printOff(p, start)); + + const binary = await build(p, start, 'resume-pause'); + + await binary.check('..p....p..', + 'off=3 pause\noff=3\noff=8 pause\noff=8\n'); + }); +}); |