Repository navigation
feat(t27b): lower try std.testing.* statements in tests like the reference - #6355
Merged
Merged
Conversation
…rence `try std.testing.expect / expectEqual / expectApproxEqAbs(...);` in a test lowers to asserts whose trap fails that test alone, as the error the reference's Zig test returns does. approxEqAbs follows Zig 0.16: a negative tolerance panics, equal values pass, NaN fails, operands evaluated once. `try` in a bench or an unreached fn is a stub trap (never analyzed). Forms the reference cannot compile get named refusals, each confirmed BLOCKED under t27c test-report. Corpus vs reference at fefecd8: counted pass 629 -> 634 of 720, checked pass 357 -> 361, mismatch 0, no regression. Closes #6354 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
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.
Closes #6354
Refs #6063
try std.testing.expect / expectEqual / expectApproxEqAbs(...);as a statement in a test now lowers incli/t27b/src/lower.rs. Per-test verdicts equal the reference (t27c gen+zig test, zig 0.16):expectEqualuses peer types, and floats compare as IEEE values.expectApproxEqAbsfollowsstd.math.approxEqAbs: a negative tolerance panics and fails the test,a == bpasses (equal infinities pass), NaN fails, and each operand is evaluated once, left to right.tryin a bench, or in a fn nothing analyzed reaches, lowers to a stub trap, because Zig never analyzes those bodies.Named refusals, each confirmed BLOCKED under
t27c test-report:ExprUnary(try) in an invariant: t27c emits an invariant as a comptime block, and Zig reports "'try' outside function scope".ExprUnary(try) in a fn: the fn gets a void/non-error return type in the reference.ExprUnary(try) on a non-error call.ExprCall(std.testing.expectApproxEqAbs) on comptime floatsandon a non-float.ExprUnary(try) std.testing.<other>.#6353's ignored-result rule is unchanged.
Corpus vs reference (
t27b corpus specs --blockers --reference t27c, fixed binaries, base fefecd8)tryblocker is in a file the reference itself blocks.Tests
cli/t27b/tests/source.rsaddstry_statements_in_tests_match_the_referenceandtry_statements_the_reference_does_not_compile_are_refused. Their verdicts were checked againstt27c test-reporton the same sources.cargo test -p t27bis green.Reference bug seen:
try h()on a void fn makes zig 0.16 report "not yet implemented" rather than a type error. It is BLOCKED either way.🤖 Generated with Claude Code