test/-ext-/string/test_too_many_dummy_encodings.rb
raw| 1 | # frozen_string_literal: false |
| 2 | require 'test/unit' |
| 3 | require "-test-/string" |
| 4 | |
| 5 | class Test_TooManyDummyEncodings < Test::Unit::TestCase |
| 6 | def test_exceed_encoding_table_size |
| 7 | assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") |
| 8 | begin; |
| 9 | require "-test-/string" |
| 10 | assert_raise_with_message(EncodingError, /too many encoding/) do |
| 11 | 1_000.times{|i| Bug::String.rb_define_dummy_encoding("R_#{i}") } # now 256 entries |
| 12 | end |
| 13 | end; |
| 14 | end |
| 15 | end |