Skip to content

Strengthen contract-clause condition diagnostic test coverage - #457

Merged
onatozmenn merged 5 commits into
mainfrom
copilot/edit-contract-clauses-test
Jul 29, 2026
Merged

Strengthen contract-clause condition diagnostic test coverage#457
onatozmenn merged 5 commits into
mainfrom
copilot/edit-contract-clauses-test

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What this changes

The contract_clauses_must_be_conditions test only asserted TYPE_MISMATCH, which allowed diagnostic wording regressions to slip through. This updates that single test to also assert rendered output contains condition/type expectation language.

  • Scope (single-test change only)

    • Updated crates/deed-typeck/tests/checking.rs::contract_clauses_must_be_conditions
    • Kept the existing diagnostic code assertion unchanged
    • Added rendered-diagnostic text assertion using rendered(&sources, &checked.diagnostics)
  • Guard added

    • Asserts the rendered message includes at least one of: "Bool", "condition", or "expected".
let text = rendered(&sources, &checked.diagnostics);
assert!(text.contains("Bool") || text.contains("condition") || text.contains("expected"), "{text}");

Why this way

Code-only assertions verify classification, not message quality. This adds a minimal, stable wording guard without overfitting to one exact sentence.

What it still does not do

It does not pin an exact full diagnostic string; it enforces key semantic wording only.

Checks

  • cargo fmt --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
  • cargo run -p deed-cli -- check examples/ and test examples/, if this touches the compiler
  • A design document under design/ updated in this PR, if this changes behaviour one of
    them describes. A design that lags the code is worse than no design.
  • Tests added for the thing that was wrong, not only for the thing that is now right. A
    guard test that only passes values the guard accepts proves nothing, and that is how
    the worst bug here went unnoticed.

AI assistance used.

Original prompt

In crates/deed-typeck/tests/checking.rs, strengthen the existing test contract_clauses_must_be_conditions.

Current test only asserts TYPE_MISMATCH. Pin the rendered wording.

Change it to:

#[test]
fn contract_clauses_must_be_conditions() {
    let (sources, checked) = check_source("module a\n\nfn f(n: Int) -> Int\n  where n,\n{ n }\n");
    assert_eq!(codes_of(&checked.diagnostics), vec![codes::TYPE_MISMATCH]);
    let text = rendered(&sources, &checked.diagnostics);
    assert!(text.contains("Bool") || text.contains("condition") || text.contains("expected"), "{text}");
}

Only edit that one test. No production code.

Copilot AI changed the title [WIP] Strengthen contract_clauses_must_be_conditions test Strengthen contract-clause condition diagnostic test coverage Jul 29, 2026
Copilot AI requested a review from onatozmenn July 29, 2026 20:47
@onatozmenn
onatozmenn marked this pull request as ready for review July 29, 2026 20:49
@onatozmenn
onatozmenn merged commit a73f3f6 into main Jul 29, 2026
2 checks passed
@onatozmenn
onatozmenn deleted the copilot/edit-contract-clauses-test branch July 29, 2026 20:56
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