From cd724294290cfd78b134e306493a6c1cf6d1703c Mon Sep 17 00:00:00 2001 From: nick evans Date: Sun, 4 Feb 2024 11:56:50 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Do=20not=20automatically=20freez?= =?UTF-8?q?e=20SearchResult?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was backward incompatible with existing usage of search results: * Fixes #262 --- lib/net/imap/search_result.rb | 8 ++------ test/net/imap/test_search_result.rb | 8 -------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/lib/net/imap/search_result.rb b/lib/net/imap/search_result.rb index 3b871191..02164dec 100644 --- a/lib/net/imap/search_result.rb +++ b/lib/net/imap/search_result.rb @@ -9,7 +9,7 @@ class IMAP # For backward compatibility, SearchResult inherits from Array. class SearchResult < Array - # Returns a frozen SearchResult populated with the given +seq_nums+. + # Returns a SearchResult populated with the given +seq_nums+. # # Net::IMAP::SearchResult[1, 3, 5, modseq: 9] # # => Net::IMAP::SearchResult[1, 3, 5, modseq: 9] @@ -22,19 +22,15 @@ def self.[](*seq_nums, modseq: nil) # ยง3.1.6]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.1.6]. attr_reader :modseq - # Returns a frozen SearchResult populated with the given +seq_nums+. + # Returns a SearchResult populated with the given +seq_nums+. # # Net::IMAP::SearchResult.new([1, 3, 5], modseq: 9) # # => Net::IMAP::SearchResult[1, 3, 5, modseq: 9] def initialize(seq_nums, modseq: nil) super(seq_nums.to_ary.map { Integer _1 }) @modseq = Integer modseq if modseq - freeze end - # Returns a frozen copy of +other+. - def initialize_copy(other); super; freeze end - # Returns whether +other+ is a SearchResult with the same values and the # same #modseq. The order of numbers is irrelevant. # diff --git a/test/net/imap/test_search_result.rb b/test/net/imap/test_search_result.rb index e048b93f..fd6060f7 100644 --- a/test/net/imap/test_search_result.rb +++ b/test/net/imap/test_search_result.rb @@ -6,14 +6,6 @@ class SearchDataTests < Test::Unit::TestCase SearchResult = Net::IMAP::SearchResult - test "#frozen?" do - assert SearchResult.new([1, 3, 5]).frozen? - assert SearchResult[1, 3, 5].frozen? - assert SearchResult[1, 3, 5, modseq: 9].frozen? - assert SearchResult[1, 3, 5, modseq: 9].clone.frozen? - assert SearchResult[1, 3, 5, modseq: 9].dup.dup.frozen? - end - test "#modseq" do assert_nil SearchResult[12, 34].modseq assert_equal 123_456_789, SearchResult[12, 34, modseq: 123_456_789].modseq