tests: the C and Rust backends get behavioural tests (Refs #2161) - #2737
Merged
Conversation
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.
Contributor
Contributor
|
📓 NotebookLM Notebook linked to this PR
This notebook contains session context, decisions, and artifacts for this work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four defects were fixed in this session, and every one emitted a green exit over output that was wrong or absent:
gen-rustwrote an emptymatchfor everyswitchgen-rustdropped the body of everyforloopgen-cemitted no loop header at all, so the body ran oncegen-ctyped an un-annotated local asint, printing 1 where the other backends print 4294967297All 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
iverilogtargets inbootstrap/tests/for a long time. C and Rust had nothing.Seven tests: generate → compile → run → check the answer
1..=3runs three timesvarswitchA 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
__auto_typefix →c_and_rust_agree_on_an_un_annotated_wide_localfails with "C truncated a u64 to int"no_rangefix → two loop tests failA green test suite proves nothing until you have watched it go red.
Refs #2161