From e7c09f4f196795e17b2eb2a2c2753401ed94252d Mon Sep 17 00:00:00 2001 From: nick evans Date: Mon, 23 Sep 2024 16:42:01 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20SequenceSet[input]=20for?= =?UTF-8?q?=20a=20SequenceSet=20input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I'm surprised there was no test for this! --- lib/net/imap/sequence_set.rb | 2 +- test/net/imap/test_sequence_set.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/net/imap/sequence_set.rb b/lib/net/imap/sequence_set.rb index cea70014..c83e316c 100644 --- a/lib/net/imap/sequence_set.rb +++ b/lib/net/imap/sequence_set.rb @@ -297,7 +297,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 diff --git a/test/net/imap/test_sequence_set.rb b/test/net/imap/test_sequence_set.rb index ce4d3219..7c79fa06 100644 --- a/test/net/imap/test_sequence_set.rb +++ b/test/net/imap/test_sequence_set.rb @@ -103,6 +103,11 @@ def compare_to_reference_set(nums, set, seqset) assert_raise DataFormatError do SequenceSet.new Set[1..20] 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 []