Skip to content
This repository was archived by the owner on Aug 15, 2026. It is now read-only.

[Corn Flakes] Swift fix flaky test: ensure generateRandomEvenNumber returns even numbers in range - #260

Draft
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/corn-flakes-detection-flaky-test-another-one
Draft

[Corn Flakes] Swift fix flaky test: ensure generateRandomEvenNumber returns even numbers in range#260
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/corn-flakes-detection-flaky-test-another-one

Conversation

Copilot AI commented May 20, 2026

Copy link
Copy Markdown
Contributor

generateRandomEvenNumber() had an intentional 5% corruption that added 1 to the result, producing odd values and causing testEvenNumberIsEven to fail ~55% of the time across 20 iterations.

Change

  • swift/Sources/CornTest/RandomMathOperations.swift: Replaced flawed implementation with Int.random(in: 0...50) * 2, guaranteeing even results in [0, 100].
// Before
var value = Int.random(in: 0..<51) * 2
if Double.random(in: 0.0..<1.0) < 0.05 {
    value += 1  // 5% chance of odd result
}
return value

// After
return Int.random(in: 0...50) * 2

Copilot AI changed the title [WIP] Fix flaky test for even number verification in CornTestTests [Corn Flakes] Swift fix flaky test: ensure generateRandomEvenNumber returns even numbers in range May 20, 2026
Copilot AI requested a review from mbianchidev May 20, 2026 12:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flaky-test] [Swift] RandomMathOperationsTests.testEvenNumberIsEven()

2 participants