diff options
author | Koichi Sasada <ko1@atdot.net> | 2022-12-15 17:53:55 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2022-12-16 10:04:37 +0900 |
commit | ae19ac5b5ba1e613a788addeb6d4d67fa65f6518 (patch) | |
tree | a431cdff5e73e1b48edb1a2f0b30578162736e68 /test/ruby/test_encoding.rb | |
parent | 15b60bb1a48b98e2ba267c88551803df5f88355e (diff) |
fixed encoding table
This reduces global lock acquiring for reading.
https://bugs.ruby-lang.org/issues/18949
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6935
Diffstat (limited to 'test/ruby/test_encoding.rb')
-rw-r--r-- | test/ruby/test_encoding.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb index 64af8b488a..cde2951413 100644 --- a/test/ruby/test_encoding.rb +++ b/test/ruby/test_encoding.rb @@ -69,7 +69,7 @@ class TestEncoding < Test::Unit::TestCase def test_extra_encoding assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; - 200.times {|i| + 100.times {|i| EnvUtil.suppress_warning { Encoding::UTF_8.replicate("dummy#{i}") } } e = Encoding.list.last @@ -160,4 +160,18 @@ class TestEncoding < Test::Unit::TestCase end end; end + + def test_exceed_encoding_table_size + assert_separately(%w[--disable=gems], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + begin + enc = Encoding::UTF_8 + 1_000.times{|i| EnvUtil.suppress_warning{ enc.replicate("R_#{i}") } } # now 256 entries + rescue EncodingError => e + assert_match(/too many encoding/, e.message) + else + assert false + end + end; + end end |