mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
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:
parent
fe61cad749
commit
b0b9f7201a
Notes:
git
2022-08-18 17:09:28 +09:00
4 changed files with 23 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue