aboutsummaryrefslogtreecommitdiffstats
path: root/test/prism
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-11-29 21:01:10 -0500
committerKevin Newton <kddnewton@gmail.com>2023-11-30 21:37:56 -0500
commita9162a44c59d85a56930e78cf1801558984db4a7 (patch)
treec7b1521dc74122b91d66d4b816cb17956ade73c7 /test/prism
parent10d3897e13f87569d6a682336141330371a902e3 (diff)
downloadruby-a9162a44c59d85a56930e78cf1801558984db4a7.tar.gz
[ruby/prism] Emacs MULE encodings
https://github.com/ruby/prism/commit/4c06b6c42e
Diffstat (limited to 'test/prism')
-rw-r--r--test/prism/encoding_test.rb36
1 files changed, 23 insertions, 13 deletions
diff --git a/test/prism/encoding_test.rb b/test/prism/encoding_test.rb
index 67652625cb..aa114b669b 100644
--- a/test/prism/encoding_test.rb
+++ b/test/prism/encoding_test.rb
@@ -6,8 +6,8 @@ require_relative "test_helper"
module Prism
class EncodingTest < TestCase
- codepoints_1byte = 0x00...0x100
- codepoints_2bytes = 0x00...0x10000
+ codepoints_1byte = 0...0x100
+ codepoints_2bytes = 0...0x10000
encodings = {
Encoding::ASCII => codepoints_1byte,
@@ -91,19 +91,29 @@ module Prism
# are 3 and 4 byte representations so it can drastically slow down the test
# suite.
if ENV["PRISM_TEST_ALL_ENCODINGS"]
- codepoints_eucjp = [*(0x00...0x10000), *(0x00...0x10000).map { |bytes| bytes | 0x8F0000 }]
- codepoints_unicode = 0x00...0x110000
+ codepoints_eucjp = [*(0...0x10000), *(0...0x10000).map { |bytes| bytes | 0x8F0000 }]
+ codepoints_unicode = 0...0x110000
+ codepoints_emacs_mule = [
+ *(0...0x80),
+ *((0x81...0x90).flat_map { |byte1| (0x90...0x100).map { |byte2| byte1 << 8 | byte2 } }),
+ *((0x90...0x9C).flat_map { |byte1| (0xA0...0x100).flat_map { |byte2| (0xA0...0x100).flat_map { |byte3| byte1 << 16 | byte2 << 8 | byte3 } } }),
+ *((0xF0...0xF5).flat_map { |byte2| (0xA0...0x100).flat_map { |byte3| (0xA0...0x100).flat_map { |byte4| 0x9C << 24 | byte3 << 16 | byte3 << 8 | byte4 } } }),
+ ]
+ encodings.clear
encodings.merge!(
- Encoding::CP51932 => codepoints_eucjp,
- Encoding::EUC_JP => codepoints_eucjp,
- Encoding::EUCJP_MS => codepoints_eucjp,
- Encoding::EUC_JIS_2004 => codepoints_eucjp,
- Encoding::UTF_8 => codepoints_unicode,
- Encoding::UTF8_MAC => codepoints_unicode,
- Encoding::UTF8_DoCoMo => codepoints_unicode,
- Encoding::UTF8_KDDI => codepoints_unicode,
- Encoding::UTF8_SoftBank => codepoints_unicode
+ Encoding::CP51932 => codepoints_eucjp,
+ Encoding::EUC_JP => codepoints_eucjp,
+ Encoding::EUCJP_MS => codepoints_eucjp,
+ Encoding::EUC_JIS_2004 => codepoints_eucjp,
+ Encoding::UTF_8 => codepoints_unicode,
+ Encoding::UTF8_MAC => codepoints_unicode,
+ Encoding::UTF8_DoCoMo => codepoints_unicode,
+ Encoding::UTF8_KDDI => codepoints_unicode,
+ Encoding::UTF8_SoftBank => codepoints_unicode,
+ Encoding::EMACS_MULE => codepoints_emacs_mule,
+ Encoding::STATELESS_ISO_2022_JP => codepoints_emacs_mule,
+ Encoding::STATELESS_ISO_2022_JP_KDDI => codepoints_emacs_mule,
)
end