From b0b9f7201acab05c2a3ad92c3043a1f01df3e17f Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 25 Jul 2022 10:21:38 +0200 Subject: 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. --- test/ruby/test_sprintf.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index f2e73eb58d..b05f4f3e44 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -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) -- cgit v1.2.3