Skip to content

tests: the C and Rust backends get behavioural tests (Refs #2161) - #2737

Merged
gHashTag merged 2 commits into
masterfrom
w699-backendtests
Aug 27, 2026
Merged

tests: the C and Rust backends get behavioural tests (Refs #2161)#2737
gHashTag merged 2 commits into
masterfrom
w699-backendtests

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

Four defects were fixed in this session, and every one emitted a green exit over output that was wrong or absent:

  • gen-rust wrote an empty match for every switch
  • gen-rust dropped the body of every for loop
  • gen-c emitted no loop header at all, so the body ran once
  • gen-c typed an un-annotated local as int, printing 1 where the other backends print 4294967297

All four were invisible to the 1,600-test suite, because those tests read the emitted text and not one of them hands it to a compiler. The Verilog backend has had iverilog targets in bootstrap/tests/ for a long time. C and Rust had nothing.

Seven tests: generate → compile → run → check the answer

test what it pins
range loop C and Rust both print 6, not 1
inclusive range 1..=3 runs three times
wide un-annotated local both print 4294967297, and are asserted equal to each other
module-level var two calls leave the counter at 2, in both backends
switch the arms are present in the Rust output

A test that cannot find its compiler skips loudly rather than passing quietly. An absent tool is not a passing test — and this file exists precisely because silence looked like success.

Verified load-bearing, not assumed

  • reverting the __auto_type fix → c_and_rust_agree_on_an_un_annotated_wide_local fails with "C truncated a u64 to int"
  • reverting the no_range fix → two loop tests fail
  • restoring both → 7/7

A green test suite proves nothing until you have watched it go red.

Refs #2161

Four defects were fixed in this session, and every one of them emitted a
green exit over output that was wrong or absent:

  * gen-rust wrote an empty `match` for every `switch`;
  * gen-rust dropped the body of every `for` loop;
  * gen-c emitted no loop header at all, so the body ran once;
  * gen-c typed an un-annotated local as `int`, printing 1 where the
    other backends print 4294967297.

All four were invisible to the 1,600-test suite, because those tests read
the emitted TEXT and not one of them hands it to a compiler. The Verilog
backend has had iverilog targets in bootstrap/tests/ for a long time. C
and Rust had nothing.

Seven tests: generate, compile with the real toolchain, RUN, and check
the printed answer.

    range loop            C and Rust both print 6, not 1
    inclusive range       1..=3 runs three times
    wide un-annotated     C and Rust both print 4294967297, and agree
    module-level var      two calls leave the counter at 2, in both
    switch                the arms are in the Rust output

A test that cannot find its compiler SKIPS LOUDLY rather than passing
quietly. An absent tool is not a passing test, and this file exists
because silence looked like success.

Verified load-bearing, not assumed. Reverting the `__auto_type` fix fails
`c_and_rust_agree_on_an_un_annotated_wide_local` with "C truncated a u64
to int"; reverting the `no_range` fix fails two of the loop tests;
restoring both returns 7/7.
@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-08-27 19:33:02 UTC

Summary

Status Count
Total Open PRs 9
PRs with Failing Checks 7
PRs with All Checks Green 2
READY 1
FAILING 7
PENDING 0

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=78bc6d9b03a1 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

Copy link
Copy Markdown
Contributor

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@gHashTag
gHashTag merged commit 2e585da into master Aug 27, 2026
32 of 33 checks passed
@gHashTag
gHashTag deleted the w699-backendtests branch August 27, 2026 19:44
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.

1 participant