Skip to content

Handle zero and negative SequenceSet min/max counts - #742

Open
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/counts-imap
Open

Handle zero and negative SequenceSet min/max counts#742
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/counts-imap

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Return an empty SequenceSet for max(0), reject negative min/max counts, and normalize integer-like counts before slicing. max(0) currently slices from -0 and returns the whole set; negative counts produce unrelated slices. Preserve oversized-count and frozen-result behavior.

Reproduction

require 'net/imap'
set = Net::IMAP::SequenceSet['1,3,5']
p set.max(0).to_s # before: "1,3,5"; after: ""
begin
  set.min(-1)
rescue ArgumentError => e
  p e.message # "negative count"
end

Verification

  • 200 focused checks; 34 failing expectations before, zero afterward. Empty/mutable/frozen/star sets, zero/positive/oversized/negative counts and objects implementing to_int are covered. Existing ✨ Add SequenceSet#min(count) and #max(count) #460 defines count behavior and 🐛 Fix SequenceSet#max(n) when cardinality < n <= size #580 fixes a separate cardinality/duplicate case already present in master.
  • Existing rake test on this isolated branch: 1726 tests, 12598 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications, Ruby 4.0.6 via rbenv. The baseline also passes all 1,726 tests; assertion counts vary slightly across runs.
  • Supplemental RuboCop Lint retains the same 48 existing findings. Ruby syntax and git diff --check pass. No repository tests, dependencies or workflows were added or modified; focused reproductions live outside the repository under the consumer's no-new-tests policy.
  • Independent branch based on 6d2ef7a636a1e2449187a83b06ac7a5baa54ead2; the runtime diff from released 0.6.6 is documentation-only before this patch.

Compatibility and limits

Intentional correction: negative counts now raise ArgumentError rather than returning a slice. Zero yields an empty set. Omitted/nil/false count behavior and scalar star handling are unchanged. Integer-like counts use the existing SequenceSet to_int coercion convention. Other Ruby/OS versions were not run locally. No production or external IMAP service was used. Local verification does not imply upstream CI approval or comprehensive behavioral coverage.

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