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

Answer architecture round 2: every builder joins its pieces through one bounded join, the readers take the engine guard, every refusal stands at the document's path, and a portable list's refusal names its own place

This commit is contained in:
2026-10-12 17:42:24 +02:00
committed by Lillem4n
parent 2b5d22cbc6
commit 3414c8690a
25 changed files with 379 additions and 249 deletions
@@ -73,13 +73,13 @@ test('refuses what the document guard refuses, and nothing else', () => {
test('refuses a paragraph whose text would pass V8\'s longest string, joining none of it', () => {
const long = 'a'.repeat(2 ** 28)
const merged = paragraph(...Array.from({ length: 9 }, () => text(long)))
assert.equal(portableDocument(document(merged)), 'unsupported-node-shape at /content/0')
assert.equal(portableDocument(document(merged)), 'unsupported-node-shape at /')
})
test('refuses an expand whose title and body together would pass V8\'s longest string', () => {
let quote: AdfNode = node('expand', { title: 'a'.repeat(1_000_000) }, { attrs: {}, content: [text('a\n'.repeat(1_108_000))], type: 'codeBlock' })
for (let level = 0; level < 240; level += 1) quote = { content: [quote], type: 'blockquote' }
assert.equal(portableDocument(document(quote)), `unsupported-node-shape at /${Array.from({ length: 241 }, () => 'content/0').join('/')}`)
assert.equal(portableDocument(document(quote)), 'unsupported-node-shape at /')
})
test('refuses nesting past 500 levels wherever the reduction walks', () => {
@@ -106,6 +106,12 @@ test('refuses nesting past 500 levels wherever the reduction walks', () => {
for (const bottom of bottoms) assert.equal(lowest(bottom), 'unsupported-nesting-depth', bottom.type)
})
test('names a list nested too deep for its spelling at its place in the caller\'s document', () => {
let deep: AdfNode = bulletList(item(said('x')))
for (let level = 0; level < largestNesting; level += 1) deep = bulletList(item(deep))
assert.match(portableDocument(document(said('a'), deep)), /^unsupported-nesting-depth at \/content\/1\/content\/0\/content\/0\//)
})
test('spells a panel as an alert in the GitHub word for its colour', () => {
const panel = (panelType: string | undefined): string =>
portable(node('panel', panelType === undefined ? {} : { localId: '01a0d99b-1f56-7a50-889a-f4375f09ee05', panelType }, said('Check it.')))