Skip to content

Validate repetition counts in the Repeat example - #987

Open
rksharma-owg wants to merge 1 commit into
apple:mainfrom
rksharma-owg:codex/repeat-count-validation
Open

rksharma-owg wants to merge 1 commit into
apple:mainfrom
rksharma-owg:codex/repeat-count-validation

Conversation

@rksharma-owg

Copy link
Copy Markdown
Contributor

The shipped Repeat example and the matching README trap for --count 0 because 1...0 is an invalid range. Negative counts also trap. Validate negative counts before running and use a zero-safe loop while preserving default output and one-based counters. Add the same validation to the two DocC examples.

Validation:

  • Four parameterized bounds cases fail on the original executable and pass after the fix. Existing default/count/help/error controls and the new one-count counter control pass.
  • Full local Linux Swift 6.3 suite: 569 tests across 56 suites passed; untouched upstream passed 566.
  • All three edited documentation snippets compile as standalone executables and pass nine default/zero/negative checks.
  • All 22 fork preflight jobs passed for 884b5786e8ddb854310a7130df3c73b50cfa03d2, covering the repository's Linux/macOS/Windows compiler matrix, Wasm, CMake, documentation, formatting and soundness.

Local macOS Command Line Tools cannot compile XCTest/Testing here, so local suite validation used Linux Docker; the full macOS SDK runners passed. The project's Windows helper skips subprocess execution, so Windows unit success is not evidence that those executable regression cases ran there. Linux and macOS run them.

Related to the count observation in #778. This does not resolve that issue's separate help-name conflict.

Allow zero repetitions without constructing an invalid range and reject negative counts with a validation error. Preserve default output and one-based counters; align the README and DocC examples and cover bounds through the executable.

Related to the count observation in apple#778.

This branch has not been deployed

No deployments
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.

1 participant