diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2024-06-28 16:04:49 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-28 16:04:49 -0400 |
| commit | 291cc913503475a204c93a53a2f470c8cc6bfca2 (patch) | |
| tree | 08e2f0fc52f61c6df20502e11e4f27f14b86482d /test/ruby | |
| parent | 7a780a3ef766e0622ade4a5fbf2518f73c38282b (diff) | |
[Bug #20598] Fix corruption of internal encoding string (#11069)
Fix corruption of internal encoding string
[Bug #20598]
Just like [Bug #20595], Encoding#name_list and Encoding#aliases can have
their strings corrupted when Encoding.default_internal is set to nil.
Co-authored-by: Matthew Valentine-House <matt@eightbitraptor.com>
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_m17n.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 58512f9041..e3fc36ef87 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1722,14 +1722,20 @@ class TestM17N < Test::Unit::TestCase end def test_encoding_names_of_default_internal - # [Bug #20595] - assert_separately(%w(-W0), "#{<<~"begin;"}\n#{<<~"end;"}") - begin; - Encoding.default_internal = Encoding::ASCII_8BIT - names = Encoding.default_internal.names - Encoding.default_internal = nil - assert_include names, "int" + "ernal", "[Bug #20595]" - end; + # [Bug #20595] [Bug #20598] + [ + "default_internal.names", + "name_list", + "aliases.keys" + ].each do |method| + assert_separately(%w(-W0), <<~RUBY) + exp_name = "int" + "ernal" + Encoding.default_internal = Encoding::ASCII_8BIT + name = Encoding.#{method}.find { |x| x == exp_name } + Encoding.default_internal = nil + assert_equal exp_name, name, "Encoding.#{method} [Bug #20595] [Bug #20598]" + RUBY + end end def test_greek_capital_gap |
