Skip to content

[Corn Flakes] Dart fix flaky test: ensure generateRandomEvenNumber returns even numbers - #253

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

[Corn Flakes] Dart fix flaky test: ensure generateRandomEvenNumber returns even numbers#253
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/corn-flakes-detection-flaky-test

Conversation

Copilot AI commented May 20, 2026

Copy link
Copy Markdown
Contributor

generateRandomEvenNumber should generate an even number was intermittently failing in Dart because the implementation could return odd values. This change removes that non-deterministic behavior and aligns tests with the intended 0..100 even-only contract.

  • Implementation: remove odd-value path

    • dart/lib/random_math_operations.dart
    • generateRandomEvenNumber() now always derives values from nextInt(51) * 2 with no conditional mutation.
  • Tests: enforce deterministic even-number contract

    • dart/test/random_math_operations_test.dart
    • Removed flaky labeling from the even-number test group.
    • Tightened bounds assertion from <= 101 to <= 100.
    • Added a repeated seeded check to validate parity/range across many calls.
int generateRandomEvenNumber() {
  return _random.nextInt(51) * 2;
}

Copilot AI changed the title [WIP] Fix flaky test for generateRandomEvenNumber [Corn Flakes] Dart fix flaky test: ensure generateRandomEvenNumber returns even numbers May 20, 2026
Copilot AI requested a review from mbianchidev May 20, 2026 12:54
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] [Dart] test/random_math_operations_test.dart › test random even number generation()

2 participants