Skip to content

Commit 8c25109

Browse files
committed
🐛 Fix Set inputs for SequenceSet
This was broken by #319
1 parent cf7e62c commit 8c25109

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/net/imap/sequence_set.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class IMAP
3030
#
3131
# SequenceSet.new may receive a single optional argument: a non-zero 32 bit
3232
# unsigned integer, a range, a <tt>sequence-set</tt> formatted string,
33-
# another sequence set, a Set (containing only numbers), or an Array
34-
# containing any of these (array inputs may be nested).
33+
# another sequence set, a Set (containing only numbers or <tt>*</tt>), or an
34+
# Array containing any of these (array inputs may be nested).
3535
#
3636
# set = Net::IMAP::SequenceSet.new(1)
3737
# set.valid_string #=> "1"
@@ -1265,7 +1265,7 @@ def input_to_tuples(obj)
12651265
when *STARS, Integer, Range then [input_to_tuple(obj)]
12661266
when String then str_to_tuples obj
12671267
when SequenceSet then obj.tuples
1268-
when Set then obj.map { to_tuple_int _1 }
1268+
when Set then obj.map { [to_tuple_int(_1)] * 2 }
12691269
when Array then obj.flat_map { input_to_tuples _1 }
12701270
when nil then []
12711271
else

test/net/imap/test_sequence_set.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def compare_to_reference_set(nums, set, seqset)
140140
assert_empty SequenceSet.new [[]]
141141
assert_empty SequenceSet.new nil
142142
assert_empty SequenceSet.new ""
143+
assert_empty SequenceSet.new Set.new
143144
end
144145

145146
test ".[] must not be empty" do
@@ -148,6 +149,7 @@ def compare_to_reference_set(nums, set, seqset)
148149
assert_raise DataFormatError do SequenceSet[[[]]] end
149150
assert_raise DataFormatError do SequenceSet[nil] end
150151
assert_raise DataFormatError do SequenceSet[""] end
152+
assert_raise DataFormatError do SequenceSet[Set.new] end
151153
end
152154

153155
test "#[non-negative index]" do
@@ -719,6 +721,18 @@ def test_inspect((expected, input, freeze))
719721
complement: "6:8,12:98,100:#{2**32 - 1}",
720722
}, keep: true
721723

724+
data "Set", {
725+
input: Set[*(9..11), :*, 99, *(1..5)],
726+
elements: [1..5, 9..11, 99, :*],
727+
entries: [1..5, 9..11, 99, :*],
728+
ranges: [1..5, 9..11, 99..99, :*..],
729+
numbers: RangeError,
730+
to_s: "1:5,9:11,99,*",
731+
normalize: "1:5,9:11,99,*",
732+
count: 10,
733+
complement: "6:8,12:98,100:#{2**32 - 1}",
734+
}, keep: true
735+
722736
data "empty", {
723737
input: nil,
724738
elements: [],

0 commit comments

Comments
 (0)