aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-30 21:54:32 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-30 21:54:32 +0000
commit88bd76c7990e14f8ca6dc1055e1d17258620ba6b (patch)
tree666a866e8cd0ca85162dcbcc841b5998ce91ada4 /test
parent4dde6e9690b47513f5ab6b993ee62ea136b24083 (diff)
downloadruby-88bd76c7990e14f8ca6dc1055e1d17258620ba6b.tar.gz
string.c (rb_str_tmp_frozen_release): release embedded strings
Handle the embedded case first, since we may have an embedded duplicate and non-embedded original string. * string.c (rb_str_tmp_frozen_release): handled embedded strings * test/ruby/test_io.rb (test_write_no_garbage): new test [ruby-core:78898] [Bug #13085] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index b146e8e321..c501edd0ab 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -3504,5 +3504,21 @@ __END__
end
end
end
+
+ def test_write_no_garbage
+ res = {}
+ ObjectSpace.count_objects(res) # creates strings on first call
+ [ 'foo'.b, '*' * 24 ].each do |buf|
+ with_pipe do |r, w|
+ before = ObjectSpace.count_objects(res)[:T_STRING]
+ n = w.write(buf)
+ after = ObjectSpace.count_objects(res)[:T_STRING]
+ assert_equal before, after,
+ 'no strings left over after write [ruby-core:78898] [Bug #13085]'
+ assert_not_predicate buf, :frozen?, 'no inadvertant freeze'
+ assert_equal buf.bytesize, n, 'wrote expected size'
+ end
+ end
+ end
end
end