mirror of
https://github.com/ruby/ruby.git
synced 2025-09-21 11:33:58 +02:00
fixed encoding table
This reduces global lock acquiring for reading. https://bugs.ruby-lang.org/issues/18949
This commit is contained in:
parent
15b60bb1a4
commit
ae19ac5b5b
Notes:
git
2022-12-16 01:04:55 +00:00
4 changed files with 61 additions and 115 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue