mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-20 07:05:44 +01:00
Answer stability round 1: 1 🔴, 0 🟡 (0 misread); register one test per case, and file the runEdge give-up
This commit is contained in:
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict'
|
|||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
|
|
||||||
import type { NodeRange } from './line-escaping.ts'
|
import type { NodeRange } from './line-escaping.ts'
|
||||||
|
import type { RunGrouping } from './inline-runs.ts'
|
||||||
import { isAdfMark, type AdfMark, type AdfNode } from '../../adf/document.ts'
|
import { isAdfMark, type AdfMark, type AdfNode } from '../../adf/document.ts'
|
||||||
import { linePass, withheldMarkFallbacks } from './inline-line.ts'
|
import { linePass, withheldMarkFallbacks } from './inline-line.ts'
|
||||||
import { portableJudgement, portableLeaves } from '../portable/inline-reduction.ts'
|
import { portableJudgement, portableLeaves } from '../portable/inline-reduction.ts'
|
||||||
@@ -78,24 +79,26 @@ const lines: { carry?: string[]; drop?: string[]; name: string; nodes: AdfNode[]
|
|||||||
]
|
]
|
||||||
|
|
||||||
for (const { carry, drop, name, nodes } of lines) {
|
for (const { carry, drop, name, nodes } of lines) {
|
||||||
test(`unspellableRuns returns ${name}`, () => {
|
for (const grouping of ['spanned', 'parted'] as const) {
|
||||||
for (const grouping of ['spanned', 'parted'] as const) {
|
if (carry !== undefined) test(`${grouping} line of ${name}: a carry takes ${carry.join(', ')}`, () => assert.deepEqual(carryRuns(nodes, grouping), carry))
|
||||||
if (carry !== undefined) {
|
if (drop !== undefined) test(`${grouping} line of ${name}: a drop takes ${drop.join(', ')}`, () => assert.deepEqual(dropRuns(nodes, grouping), drop))
|
||||||
const pass = linePass(nodes, 'paragraph', [], withheldMarkFallbacks(nodes, 'lossless'), grouping)
|
}
|
||||||
assert.ok(pass.ok)
|
}
|
||||||
assert.ok(pass.value.fallback !== undefined && pass.value.fallback !== 'opening-link')
|
|
||||||
assert.deepEqual(named(pass.value.fallback), carry)
|
function carryRuns(nodes: readonly AdfNode[], grouping: RunGrouping): string[] {
|
||||||
}
|
const pass = linePass(nodes, 'paragraph', [], withheldMarkFallbacks(nodes, 'lossless'), grouping)
|
||||||
if (drop !== undefined) {
|
assert.ok(pass.ok)
|
||||||
const leaves = portableLeaves(nodes, 'paragraph', { depth: 0, path: [], sources: new Map() })
|
assert.ok(pass.value.fallback !== undefined && pass.value.fallback !== 'opening-link')
|
||||||
assert.ok(leaves.ok)
|
return named(pass.value.fallback)
|
||||||
const judged = portableJudgement(leaves.value, grouping, 'paragraph', [])
|
}
|
||||||
assert.ok(judged.ok)
|
|
||||||
assert.ok(judged.value.kind === 'fallback' && judged.value.fallback.kind === 'unspellable-run')
|
function dropRuns(nodes: readonly AdfNode[], grouping: RunGrouping): string[] {
|
||||||
assert.deepEqual(named(judged.value.fallback.runs), drop)
|
const leaves = portableLeaves(nodes, 'paragraph', { depth: 0, path: [], sources: new Map() })
|
||||||
}
|
assert.ok(leaves.ok)
|
||||||
}
|
const judged = portableJudgement(leaves.value, grouping, 'paragraph', [])
|
||||||
})
|
assert.ok(judged.ok)
|
||||||
|
assert.ok(judged.value.kind === 'fallback' && judged.value.fallback.kind === 'unspellable-run')
|
||||||
|
return named(judged.value.fallback.runs)
|
||||||
}
|
}
|
||||||
|
|
||||||
function marked(types: readonly string[], text: string): AdfNode {
|
function marked(types: readonly string[], text: string): AdfNode {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
`Bar = 0.1`
|
`Bar = 0.1`
|
||||||
|
|
||||||
`Next ID = 176`
|
`Next ID = 177`
|
||||||
|
|
||||||
## Items
|
## Items
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||
| 153 | 0.4.0 | | question | **Decide whether `src/markdown/` root may import `emit/`, `parse/` or `portable/`, and hold the answer in `.oxlintrc.json` and §The source parts by ADF and format.** | 1 | 2 | 2 | 3 | 2 | code health by 3 | 26.2 |
|
| 153 | 0.4.0 | | question | **Decide whether `src/markdown/` root may import `emit/`, `parse/` or `portable/`, and hold the answer in `.oxlintrc.json` and §The source parts by ADF and format.** | 1 | 2 | 2 | 3 | 2 | code health by 3 | 26.2 |
|
||||||
| 175 | 0.4.0 | | | **Delete the guards in `tryTaskList` that `reduceToPortable` makes unreachable, once a test shows `adfToPortableMarkdown` reaches none of them.** | 1 | 1 | 1 | 1 | 2 | code health by 2 | 17.4 |
|
| 175 | 0.4.0 | | | **Delete the guards in `tryTaskList` that `reduceToPortable` makes unreachable, once a test shows `adfToPortableMarkdown` reaches none of them.** | 1 | 1 | 1 | 1 | 2 | code health by 2 | 17.4 |
|
||||||
|
| 176 | 0.4.0 | | | **Delete `runEdge`'s `standing === 'moves'` give-up, and any code only it needs, once a test or an argument shows `runEdge` never reaches it, or else pin the case with a hand-worked line.** | 1 | 1 | 2 | 2 | 2 | code health by 2 | 17.4 |
|
||||||
| 45 | 0.4.0 | | defect | **Replace `isAdfDocument` with a reader returning `Result<AdfDocument>`.** | 2 | 1 | 3 | 4 | 3 | 1 by 2 | 13.1 |
|
| 45 | 0.4.0 | | defect | **Replace `isAdfDocument` with a reader returning `Result<AdfDocument>`.** | 2 | 1 | 3 | 4 | 3 | 1 by 2 | 13.1 |
|
||||||
| 127 | 0.4.0 | | principle | **Hold what `entity-references.test.ts`, `json-text.test.ts` and `result.test.ts` check by asserting outcomes, so none reads source text.** | 2 | 2 | 1 | 3 | 3 | code health by 2 | 13.1 |
|
| 127 | 0.4.0 | | principle | **Hold what `entity-references.test.ts`, `json-text.test.ts` and `result.test.ts` check by asserting outcomes, so none reads source text.** | 2 | 2 | 1 | 3 | 3 | code health by 2 | 13.1 |
|
||||||
| 159 | 0.4.0 | | | **Delete `taskBlocks`'s branch that writes the task marker as its own paragraph, once a test shows no block task item reaches it.** | 1 | 1 | 1 | 1 | 1 | code health by 1 | 10.5 |
|
| 159 | 0.4.0 | | | **Delete `taskBlocks`'s branch that writes the task marker as its own paragraph, once a test shows no block task item reaches it.** | 1 | 1 | 1 | 1 | 1 | code health by 1 | 10.5 |
|
||||||
@@ -80,6 +81,13 @@ files, with its `ci.sh` probe, extends the decision.
|
|||||||
nesting refusal's path comes from `reduceToPortable`. Found by mutation testing for item 128,
|
nesting refusal's path comes from `reduceToPortable`. Found by mutation testing for item 128,
|
||||||
2026-11-08.
|
2026-11-08.
|
||||||
|
|
||||||
|
### 176. Delete `runEdge`'s `standing === 'moves'` give-up, and any code only it needs, once a test or an argument shows `runEdge` never reaches it, or else pin the case with a hand-worked line.
|
||||||
|
|
||||||
|
In `src/markdown/emit/unspellable-runs.ts`, Stryker's mutants of `runEdge`'s
|
||||||
|
`if (standing === 'moves') return undefined` survive the hand-worked tests, and 50,000 fuzz runs
|
||||||
|
comparing the code with the mutant found no output differ. Found on PR 145, 2026-11-09. The
|
||||||
|
comprehension seats found `runEdge` hard to read (`larv-review places`); make it easier.
|
||||||
|
|
||||||
### 45. Replace `isAdfDocument` with a reader returning `Result<AdfDocument>`.
|
### 45. Replace `isAdfDocument` with a reader returning `Result<AdfDocument>`.
|
||||||
|
|
||||||
Lands with item 77: the reader returns item 77's copy. Goal 1 has every call return a result; the
|
Lands with item 77: the reader returns item 77's copy. Goal 1 has every call return a result; the
|
||||||
|
|||||||
Reference in New Issue
Block a user