summaryrefslogtreecommitdiff
path: root/test/-ext-/string/test_fstring.rb
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2021-03-19 11:29:06 +0100
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-03-22 21:37:48 +0900
commit7e8a9af9db42a21f6a1125a29e98c45ff9d5833b (patch)
tree67c6fe4c12f8d4fdc8365a33ebee6bc37750c157 /test/-ext-/string/test_fstring.rb
parent5b272a645322c2ffe0f73c523d64832678d0de5f (diff)
rb_enc_interned_str: handle autoloaded encodings
If called with an autoloaded encoding that was not yet initialized, `rb_enc_interned_str` would crash with a NULL pointer exception. See: https://github.com/ruby/ruby/pull/4119#issuecomment-800189841
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4290
Diffstat (limited to 'test/-ext-/string/test_fstring.rb')
-rw-r--r--test/-ext-/string/test_fstring.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/-ext-/string/test_fstring.rb b/test/-ext-/string/test_fstring.rb
index 76afa30e147..9b4956ecef4 100644
--- a/test/-ext-/string/test_fstring.rb
+++ b/test/-ext-/string/test_fstring.rb
@@ -12,6 +12,22 @@ class Test_String_Fstring < Test::Unit::TestCase
yield fstr
end
+ def test_rb_enc_interned_str_autoloaded_encoding
+ assert_separately([], <<~RUBY)
+ require '-test-/string'
+ assert_include(Encoding::Windows_31J.inspect, 'autoload')
+ Bug::String.rb_enc_interned_str(Encoding::Windows_31J)
+ RUBY
+ end
+
+ def test_rb_enc_str_new_autoloaded_encoding
+ assert_separately([], <<~RUBY)
+ require '-test-/string'
+ assert_include(Encoding::Windows_31J.inspect, 'autoload')
+ Bug::String.rb_enc_str_new(Encoding::Windows_31J)
+ RUBY
+ end
+
def test_instance_variable
str = __method__.to_s * 3
str.instance_variable_set(:@test, 42)