summaryrefslogtreecommitdiff
path: root/test/objspace
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-26 17:27:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-26 17:27:01 +0000
commit4760b9824fc4e6ce195249e7b1101bce714b12bd (patch)
tree14acbf8880bc0a74cc04bbef5c3a69a033c05cdf /test/objspace
parentfaaec02a2dbe20b83c9bd13a7b0a212fdb991a32 (diff)
string.c: fix memsize of frozen shared string
* string.c (str_new4): copy the original capacity so that memsize of frozen shared string returns correct size. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/objspace')
-rw-r--r--test/objspace/test_objspace.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index f3bb3cd..83cd6d3 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -24,6 +24,14 @@ class TestObjSpace < Test::Unit::TestCase
ObjectSpace.memsize_of(//.match("")))
end
+ def test_memsize_of_root_shared_string
+ a = "hello" * 5
+ b = a.dup
+ c = nil
+ ObjectSpace.each_object(String) {|x| break c = x if x == a and x.frozen?}
+ assert_equal([0, 0, 26], [a, b, c].map {|x| ObjectSpace.memsize_of(x)})
+ end
+
def test_argf_memsize
size = ObjectSpace.memsize_of(ARGF)
assert_kind_of(Integer, size)