rb_str_resize: Only clear coderange on truncation

If we are expanding the string or only stripping extra capacity
then coderange won't change, so clearing it is wasteful.
This commit is contained in:
Jean Boussier 2022-07-25 10:21:38 +02:00
parent fe61cad749
commit b0b9f7201a
Notes: git 2022-08-18 17:09:28 +09:00
4 changed files with 23 additions and 8 deletions

View file

@ -507,6 +507,16 @@ class TestSprintf < Test::Unit::TestCase
end
end
def test_coderange
format_str = "wrong constant name %s"
interpolated_str = "\u3042"
assert_predicate format_str, :ascii_only?
refute_predicate interpolated_str, :ascii_only?
str = format_str % interpolated_str
refute_predicate str, :ascii_only?
end
def test_named_default
h = Hash.new('world')
assert_equal("hello world", "hello %{location}" % h)