3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-21 07:32:58 +01:00

Answer principles round 1: 0 🔴, 2 🟡 (0 misread); writtenText alone tracks its prefixes, the walk's bound comment says what the check does now, markdown tested at the bound

This commit is contained in:
2026-10-29 14:07:44 +01:00
committed by Lillem4n
parent 28ae354315
commit 1ff3ad6e9b
4 changed files with 41 additions and 21 deletions
+16
View File
@@ -67,6 +67,22 @@ test('refuses a quote whose prefixed lines would pass V8\'s longest string', ()
assert.equal(pastTheBound(adfToLosslessMarkdown(document({ content: [code, code], type: 'blockquote' }))), true)
})
// A code block spelled in 55 characters around its text; the blocks between them take a blank line, and the markdown a closing line break.
function codeBlockOf(textLength: number): AdfNode {
return { attrs: {}, content: [{ text: `${'a'.repeat(textLength - 1)}\n`, type: 'text' }], type: 'codeBlock' }
}
test('refuses markdown one character past V8\'s longest string', () => {
const code = codeBlockOf(268_435_390)
assert.equal(pastTheBound(adfToLosslessMarkdown(document(code, code))), true)
})
test('writes markdown exactly as long as V8\'s longest string', () => {
const code = codeBlockOf(178_956_908)
const written = adfToLosslessMarkdown(document(code, code, code))
assert.equal(written.ok && written.value.length, 536870888)
})
test('refuses text past V8\'s longest string', () => {
const long = 'a'.repeat(2 ** 28)
const result = adfToLosslessMarkdown(document(paragraph({ text: long, type: 'text' }, { text: long, type: 'text' }, { text: long, type: 'text' })))