[ruby/json] Assume Encoding is defined

https://github.com/ruby/json/commit/8713aa4812
This commit is contained in:
Jean Boussier 2024-10-17 19:12:58 +02:00 committed by Hiroshi SHIBATA
parent 20dc1e5c25
commit 8feed977a0
2 changed files with 5 additions and 7 deletions

View File

@ -479,9 +479,7 @@ EOT
end
end
if defined?(Encoding)
def test_nonutf8_encoding
assert_equal("\"5\u{b0}\"", "5\xb0".force_encoding("iso-8859-1").to_json)
end
def test_nonutf8_encoding
assert_equal("\"5\u{b0}\"", "5\xb0".force_encoding("iso-8859-1").to_json)
end
end

View File

@ -24,13 +24,13 @@ class JSONParserTest < Test::Unit::TestCase
source = "{}".encode("UTF-16")
JSON::Parser.new(source)
assert_equal Encoding::UTF_16, source.encoding
end if defined?(Encoding::UTF_16)
end
def test_argument_encoding_for_binary
source = "{}".encode("ASCII-8BIT")
JSON::Parser.new(source)
assert_equal Encoding::ASCII_8BIT, source.encoding
end if defined?(Encoding::ASCII_8BIT)
end
def test_error_message_encoding
pend if RUBY_ENGINE == 'truffleruby'
@ -42,7 +42,7 @@ class JSONParserTest < Test::Unit::TestCase
}
assert_equal(Encoding::UTF_8, e.message.encoding, bug10705)
assert_include(e.message, json, bug10705)
end if defined?(Encoding::UTF_8) and defined?(JSON::Ext::Parser)
end if defined?(JSON::Ext::Parser)
def test_parsing
parser = JSON::Parser.new('"test"')