Skip to content

Commit 85fcc81

Browse files
committed
♻️ Allow VanishedData#uids to be SequenceSet.empty
This isn't a valid server response. But it's useful as a null object.
1 parent 5de57d9 commit 85fcc81

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/net/imap/vanished_data.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class VanishedData < Data.define(:uids, :earlier)
1919
# * +uids+ will be converted by SequenceSet.[].
2020
# * +earlier+ will be converted to +true+ or +false+
2121
def initialize(uids:, earlier:)
22-
uids = SequenceSet[uids]
22+
uids = SequenceSet[uids] unless uids.equal? SequenceSet.empty
2323
earlier = !!earlier
2424
super
2525
end

test/net/imap/test_vanished_data.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ class VanishedDataTest < Net::IMAP::TestCase
2929
assert_raise DataFormatError do VanishedData.new nil, true end
3030
end
3131

32+
test ".new allows SequenceSet.empty singleton, not other empty sets" do
33+
assert_same SequenceSet.empty, VanishedData[SequenceSet.empty, true].uids
34+
assert_raise DataFormatError do VanishedData[SequenceSet.new, true] end
35+
assert_raise DataFormatError do VanishedData[SequenceSet.new.freeze, true] end
36+
end
37+
3238
test ".[uids: string, earlier: bool]" do
3339
vanished = VanishedData[uids: "1,3:5,7", earlier: true]
3440
assert_equal SequenceSet["1,3:5,7"], vanished.uids

0 commit comments

Comments
 (0)