Skip to content

Commit

Permalink
🐛 Fix SequenceSet[input] for a SequenceSet input
Browse files Browse the repository at this point in the history
I'm surprised there was no test for this!
  • Loading branch information
nevans committed Sep 24, 2024
1 parent d8b68bc commit 0cfc69b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/net/imap/sequence_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class << self
# Use ::new to create a mutable or empty SequenceSet.
def [](first, *rest)
if rest.empty?
if first.is_a?(SequenceSet) && set.frozen? && set.valid?
if first.is_a?(SequenceSet) && first.frozen? && first.valid?
first
else
new(first).validate.freeze
Expand Down
5 changes: 5 additions & 0 deletions test/net/imap/test_sequence_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ def compare_to_reference_set(nums, set, seqset)
assert_raise DataFormatError do SequenceSet.new Time.now end
end

test ".[frozen SequenceSet] returns that SequenceSet" do
frozen_seqset = SequenceSet[123..456]
assert_same frozen_seqset, SequenceSet[frozen_seqset]
end

test ".new, input may be empty" do
assert_empty SequenceSet.new
assert_empty SequenceSet.new []
Expand Down

0 comments on commit 0cfc69b

Please sign in to comment.