diff options
author | Kevin Newton <kddnewton@gmail.com> | 2023-11-11 22:52:23 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-11-16 17:39:30 +0000 |
commit | ca789e7232f95f485198a459fdf23bff16a2c370 (patch) | |
tree | aa6ee8a033794c9fade46b04da9baab5cab540a2 /test/prism/encoding_test.rb | |
parent | aebc6e8b8db259b7eeee203f6ec4137019081d70 (diff) | |
download | ruby-ca789e7232f95f485198a459fdf23bff16a2c370.tar.gz |
[ruby/prism] Add windows-1250 encoding
https://github.com/ruby/prism/commit/a362535ca4
Diffstat (limited to 'test/prism/encoding_test.rb')
-rw-r--r-- | test/prism/encoding_test.rb | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/test/prism/encoding_test.rb b/test/prism/encoding_test.rb index f3a24fa9dc..9e18989ad3 100644 --- a/test/prism/encoding_test.rb +++ b/test/prism/encoding_test.rb @@ -4,45 +4,49 @@ require_relative "test_helper" module Prism class EncodingTest < TestCase - %w[ - ascii - ascii-8bit - big5 - binary - euc-jp - gbk - iso-8859-1 - iso-8859-2 - iso-8859-3 - iso-8859-4 - iso-8859-5 - iso-8859-6 - iso-8859-7 - iso-8859-8 - iso-8859-9 - iso-8859-10 - iso-8859-11 - iso-8859-13 - iso-8859-14 - iso-8859-15 - iso-8859-16 - koi8-r - shift_jis - sjis - us-ascii - utf-8 - utf8-mac - windows-31j - windows-1251 - windows-1252 - CP1251 - CP1252 - CP51932 - ].each do |encoding| - define_method "test_encoding_#{encoding}" do - result = Prism.parse("# encoding: #{encoding}\n'string'") - actual = result.value.statements.body.first.unescaped.encoding - assert_equal Encoding.find(encoding), actual + [ + "US-ASCII", + "ASCII-8BIT", + "Big5", + "CP51932", + "EUC-JP", + "GBK", + "ISO-8859-1", + "ISO-8859-2", + "ISO-8859-3", + "ISO-8859-4", + "ISO-8859-5", + "ISO-8859-6", + "ISO-8859-7", + "ISO-8859-8", + "ISO-8859-9", + "ISO-8859-10", + "ISO-8859-11", + "ISO-8859-13", + "ISO-8859-14", + "ISO-8859-15", + "ISO-8859-16", + "KOI8-R", + "Shift_JIS", + "Windows-31J", + "UTF-8", + "UTF8-MAC", + "Windows-1250", + "Windows-1251", + "Windows-1252", + ].each do |canonical_name| + encoding = Encoding.find(canonical_name) + + encoding.names.each do |name| + # Even though UTF-8-MAC is an alias for UTF8-MAC, CRuby treats it as + # UTF-8. So we'll skip this test. + next if name == "UTF-8-MAC" + + define_method "test_encoding_#{name}" do + result = Prism.parse("# encoding: #{name}\n'string'") + actual = result.value.statements.body.first.unescaped.encoding + assert_equal encoding, actual + end end end |