Repository navigation
fix(worker): reject NaN in float checker - #76
sainimal1ba-hue wants to merge 4 commits into
Conversation
Add NaN checks for expected and actual values in judge function. Signed-off-by: a12san <sainimal1ba@gmail.com>
Signed-off-by: a12san <sainimal1ba@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughFloat output judging now returns ChangesFloat output judging
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to
|
|
fixed. |
Summary
Fix an incorrect Accepted verdict in the floating-point output checker when either output contains
NaN.Motivation
strconv.ParseFloatrecognizesNaNas a valid floating-point value. However, the existing epsilon comparison does not detect mismatches involvingNaN, because comparisons involvingNaNreturn false.Consequently, a submission can incorrectly receive an Accepted verdict even when its numeric output is invalid.
Implementation notes
Added an explicit
math.IsNaNcheck before applying epsilon comparison.The change preserves existing behavior for ordinary floating-point values, infinity values, and nonnumeric tokens. It introduces no dependencies or API changes.
Questions for the reviewer
Q1 — What existing tests cover the code you changed?
A: The existing
TestJudgeFloattest ininternal/worker/judge_test.gocovers finite floating-point comparisons, epsilon tolerance, token counts, and nonnumeric tokens.Q2 — What new tests did you add, and what cases do they cover?
A: Added
TestJudgeFloatRejectsNaN, covering NaN in expected output, actual output, both outputs, and later tokens. The test also checks infinity handling and an ordinary finite comparison.Q3 — Does this change affect any authenticated or unauthenticated API paths? If yes, how?
A: It does not change authentication, routing, or API contracts. It corrects floating-point judging behavior for submitted executions regardless of caller authentication.
Q4 — Did you run
golangci-lint runlocally and get 0 issues?A: [Fill in your actual result after running lint.]
Q5 — Is this the only open PR you have against
development?A: [Confirm your actual PR status.]
Checklist
go test -race -count=1 -timeout=120s ./...passes locallygolangci-lint run --timeout=5mreports 0 issuesgofmt -s -l .reports no unformatted filesSummary by CodeRabbit
NaNvalues as incorrect answers.NaN, infinity, later-token mismatches, and normally matching float outputs.