Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

test: check random edit sequences against a reference edit model - #381

Merged
antfu merged 1 commit into
Rich-Harris:masterfrom
antfubot:test/edit-model-fuzz
Oct 27, 2026
Merged

antfu merged 1 commit into
Rich-Harris:masterfrom
antfubot:test/edit-model-fuzz

Conversation

@antfubot

Copy link
Copy Markdown
Contributor

Adds tests/fuzz/. It holds a small reference model of magic-string's edit semantics (per-character text plus left/right inserts at each boundary), and a seeded harness. The harness runs random sequences of append*/prepend*/update/overwrite/remove/reset against IntegrityCheckingMagicString and the model. After every op it checks that:

Most of the recent fix: PRs (#352–#367) were found by contributors' out-of-tree fuzzers. This keeps the same kind of check in the repo. It runs 1000 sequences in about 3 s under pnpm test. Run FUZZ_SEQUENCES=100000 FUZZ_SEED=2 pnpm exec vitest run tests/fuzz for a deep run.

There are no divergences at 100k sequences × 2 seeds. Two open questions are recorded in tests/fuzz/FINDINGS.md:

  • whether splitting inside a replacement should depend on earlier empty inserts
  • whether slice anchors inside removed text should

Both currently do, and the model follows the library on each. No changes under src/.

Plan: plans/011-edit-model-oracle-fuzz-spike.md in #370.

This PR was created with the help of an agent.

@antfu
antfu merged commit 0c6698f into Rich-Harris:master Oct 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants