Skip to content

test(diff): address review feedback on QuickCheck suite - #4060

Merged
bobzhang merged 1 commit into
mainfrom
agent/quickcheck-diff-review-followup
Aug 15, 2026
Merged

test(diff): address review feedback on QuickCheck suite#4060
bobzhang merged 1 commit into
mainfrom
agent/quickcheck-diff-review-followup

Conversation

@bobzhang

Copy link
Copy Markdown
Contributor

Follow-up to #4047 (merged), addressing Copilot's three inline review comments on diff/quickcheck_test.mbt:

  1. range_text docstring — clarified that only non-empty header ranges are 1-based: an empty range is anchored to the line before it, so its rendered anchor may legally be 0 (e.g. @@ -0,0 +1 @@ for an insertion at the start of a file).
  2. CI-cost knobs centralized — every @quickcheck.check call now uses shared QC_COUNT / QC_MAX_SIZE constants (plus QC_LONG_MAX_SIZE for the deliberately longer two-symbol repetition property), so the suite's cost is tunable in one place. The values are unchanged (200 cases; sizes 100/200) because measurement showed no runtime problem: moon test -p moonbitlang/core/diff (all 127 tests, warm build) runs in ~0.17s on wasm-gc, ~0.28s on js, and ~0.16s on native, both before and after this change — well under any CI concern, so coverage was not reduced.
  3. Adjacency state machine — the magic-number prev state (0/1/2/3/4) duplicated across script_ok and lev_ok is replaced by a shared PrevEdit enum (ScriptStart / DeleteRun / InsertRun / EqualRun / ReplaceRun), making the coalescing and Delete-before-adjacent-Insert invariants self-documenting.

No change to what the properties assert; all 127 diff tests pass on wasm-gc, js, and native, and moon info && moon fmt produce no further changes.

🤖 Generated with Claude Code

Address the three Copilot review comments on #4047:

- Clarify the range_text docstring: only non-empty header ranges are
  1-based; an empty range is anchored to the line before it, so its
  rendered anchor may legally be 0 (e.g. `@@ -0,0 +1 @@` for an
  insertion at the start of a file).
- Centralize the QuickCheck knobs as QC_COUNT / QC_MAX_SIZE /
  QC_LONG_MAX_SIZE constants used by every check call, so the suite's
  CI cost is tunable in one place. Values are unchanged (200 cases,
  sizes 100/200); the whole diff package tests in ~0.2-0.3s per target,
  so no coverage was reduced.
- Replace the magic-number `prev` adjacency state in script_ok/lev_ok
  with a shared PrevEdit enum (ScriptStart/DeleteRun/InsertRun/
  EqualRun/ReplaceRun) so the coalescing and Delete-before-Insert
  invariants are self-documenting.

No behavioral change to what the properties assert.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 15, 2026 01:20
@bobzhang
bobzhang enabled auto-merge (rebase) August 15, 2026 01:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a follow-up refinement to the diff QuickCheck property-test suite, focusing on clarifying unified-diff header semantics and making the test invariants/configuration easier to maintain without changing what the properties assert.

Changes:

  • Centralizes QuickCheck runtime knobs (count, max_size) into shared constants used by all properties.
  • Replaces duplicated numeric “previous edit” state tracking with a shared PrevEdit enum for script adjacency/invariant checking.
  • Clarifies the range_text documentation to explicitly allow 0 anchors for empty ranges at the start of a file.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread diff/quickcheck_test.mbt
/// Used to enforce the documented adjacency rules: adjacent edits of the
/// same kind must be coalesced, and a replacement is emitted as `Delete`
/// before `Insert`, so a delete may never directly follow an insert.
enum PrevEdit {
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 6060

Coverage remained the same at 90.666%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 17645
Covered Lines: 15998
Line Coverage: 90.67%
Coverage Strength: 150668.42 hits per line

💛 - Coveralls

@bobzhang
bobzhang disabled auto-merge August 15, 2026 02:10
@bobzhang
bobzhang merged commit d5a4518 into main Aug 15, 2026
20 checks passed
@bobzhang
bobzhang deleted the agent/quickcheck-diff-review-followup branch August 15, 2026 02:10
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.

3 participants