Bug #15960 ยป 2256.patch
| string.c | ||
|---|---|---|
|
return str;
|
||
|
}
|
||
|
if (!OBJ_FROZEN(str))
|
||
|
rb_str_resize(str, RSTRING_LEN(str));
|
||
|
fstr = register_fstring(str);
|
||
|
if (!bare) {
|
||
| test/-ext-/string/test_capacity.rb | ||
|---|---|---|
|
open(__FILE__) {|f|s = f.read(1024*1024)}
|
||
|
assert_operator(capa(s), :<=, s.bytesize+4096)
|
||
|
end
|
||
|
def test_literal_capacity
|
||
|
s = "I am testing string literal capacity"
|
||
|
assert_equal(s.length, capa(s))
|
||
|
end
|
||
|
def test_capacity_frozen
|
||
|
s = String.new("I am testing", capacity: 1000)
|
||
|
s << "fstring capacity"
|
||
|
s.freeze
|
||
|
assert_equal(s.length, capa(s))
|
||
|
end
|
||
|
def test_capacity_fstring
|
||
|
s = String.new("I am testing", capacity: 1000)
|
||
|
s << "fstring capacity"
|
||
|
s = -s
|
||
|
assert_equal(s.length, capa(s))
|
||
|
end
|
||
|
end
|
||