uttrflow / uttrflow/uttrflow-swift
Test PieceJoiner.laidOut with empty pieces, a single piece, and a piece ending on a bare "number"
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## What happens
`Sources/UttrflowPipeline/PieceJoiner.swift` joins the pieces of a long dictation. These early returns have never run:
- line 72: a piece that is empty or only whitespace is skipped;
- line 76: when only one non-empty piece remains, its text is returned without any list or paragraph layout;
- line 109: a restatement check at the very first word;
- lines 158 and 161: `itemise` finding no body after the sequence word;
- line 176: `sequence` when a piece ends on the prefix ("number" or "point") with nothing after it;
- line 205: `opensTopic` for a word no longer present.
Measured on origin/main `26d7bc1` with `swift test --enable-code-coverage` (5,384 tests, all passing) and `xcrun llvm-cov export` over the test binary. The regions named below have an execution count of 0: no test runs them, so a change that breaks them passes `make verify`.
## Why it matters
Long dictations are cut into pieces at pauses, and a pause can produce an empty piece. If the empty-piece skip or the single-piece early return is broken, the joined text can gain a stray bullet, a blank paragraph, or lose a word at a seam. All of that lands in the user's document.
## How to reproduce
Run `swift test --enable-code-coverage`, then `xcrun llvm-cov show -instr-profile .build/debug/codecov/default.profdata .build/debug/UttrflowPackageTests.xctest/Contents/MacOS/UttrflowPackageTests Sources/UttrflowPipeline/PieceJoiner.swift` and look for the `0` counts on the lines named above.
## Acceptance criteria
- `laidOut(["", "first buy milk", " "], under: )` returns the one piece's text unchanged, with no bullet.
- `laidOut(["first fix the build", "number"], ...)` does not crash, and keeps "number" as a word.
- Two pieces where the second is only a sequence word ("first buy milk", "second") do not make an empty list item.
- Each new test fails when the branch it covers is broken. Check this by hand before opening the PR: temporarily change the branch (flip the condition or return the other value), see the test fail, then restore it.
## Where to start
- `Tests/UttrflowPipelineTests/PieceJoinerTests.swift`. It already builds `DestinationFormatter` values with and without `.lists` and `.paragraphs`.
Read `CONTRIBUTING.md` first. Iterate with `swift test --filter `, then run `make verify` before pushing. Only tests change; no product code needs to.
**Size:** S.
Contributor guide
Research direction
Read CONTRIBUTING.md, then open Tests/UttrflowPipelineTests/PieceJoinerTests.swift and follow its existing DestinationFormatter setups. Add focused tests for the listed early-return branches, including empty pieces, a single piece, sequence-only endings, and a bare "number"; run the filtered tests, then make verify. Done means the tests assert the required output and no crash, and fail when each covered branch is temporarily inverted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100