Skip to content

[Corn Flakes] Go fix flaky test: ensure GenerateRandomEvenNumber always returns even numbers - #259

Draft
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-flaky-test-validate-even-number
Draft

[Corn Flakes] Go fix flaky test: ensure GenerateRandomEvenNumber always returns even numbers#259
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-flaky-test-validate-even-number

Conversation

Copilot AI commented May 20, 2026

Copy link
Copy Markdown
Contributor

TestGenerateRandomEvenNumber in Go was persistently flaky because GenerateRandomEvenNumber could return odd values. This change removes the probabilistic odd-path so generated values are always even and within the documented range.

  • Generator behavior

    • Simplified GenerateRandomEvenNumber to deterministically produce only even numbers in [0, 100].
    • Removed the intentional 5% corruption branch that could return odd numbers.
  • Test alignment

    • Updated the even-number test range assertion to match the documented contract (<= 100, not <= 101).
    • Removed stale flaky-test commentary tied to the old intentional flaw.
// GenerateRandomEvenNumber returns a random even number between 0 and 100 (inclusive).
func GenerateRandomEvenNumber(rng *rand.Rand) int {
	return rng.Intn(51) * 2
}

Copilot AI changed the title [WIP] Fix flaky test for generating random even number [Corn Flakes] Go fix flaky test: ensure GenerateRandomEvenNumber always returns even numbers May 20, 2026
Copilot AI requested a review from mbianchidev May 20, 2026 13:04
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.

[flaky-test] [Go] com/mbianchidev/corn-test/golang/mathops.TestGenerateRandomEvenNumber()

2 participants