summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-18 08:35:42 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-18 08:35:42 +0000
commit3993fbb5f6bfdae0bce040988d7e2dd632247cdc (patch)
tree5623b4177aaba25470e3348127847abd2c3c6f15 /test
parentc66c5f3c6c595254e5eb4c71d98d22453c7fd329 (diff)
merge revision(s) 62099: [Backport #14416]
net/pop: make modified strings mutable Thanks to Michael Zimmerman for the bug report * lib/net/pop.rb: make modified strings mutable [ruby-core:85210] [Bug #14416] * test/net/pop/test_pop.rb: new test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@64443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/net/pop/test_pop.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/net/pop/test_pop.rb b/test/net/pop/test_pop.rb
index 666aac0db6..f4c807a7a8 100644
--- a/test/net/pop/test_pop.rb
+++ b/test/net/pop/test_pop.rb
@@ -64,6 +64,35 @@ class TestPOP < Test::Unit::TestCase
end
end
+ def test_popmail
+ # totally not representative of real messages, but
+ # enough to test frozen bugs
+ lines = [ "[ruby-core:85210]" , "[Bug #14416]" ].freeze
+ command = Object.new
+ command.instance_variable_set(:@lines, lines)
+
+ def command.retr(n)
+ @lines.each { |l| yield "#{l}\r\n" }
+ end
+
+ def command.top(number, nl)
+ @lines.each do |l|
+ yield "#{l}\r\n"
+ break if (nl -= 1) <= 0
+ end
+ end
+
+ net_pop = :unused
+ popmail = Net::POPMail.new(1, 123, net_pop, command)
+ res = popmail.pop
+ assert_equal "[ruby-core:85210]\r\n[Bug #14416]\r\n", res
+ assert_not_predicate res, :frozen?
+
+ res = popmail.top(1)
+ assert_equal "[ruby-core:85210]\r\n", res
+ assert_not_predicate res, :frozen?
+ end
+
def pop_test(apop=false)
host = 'localhost'
server = TCPServer.new(host, 0)