Skip to content

Commit

Permalink
Fix Rubocop warnings for core/encoding/compatible_spec.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin committed Nov 6, 2024
1 parent 0c1e155 commit 7723ed9
Showing 1 changed file with 31 additions and 33 deletions.
64 changes: 31 additions & 33 deletions core/encoding/compatible_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,39 +168,37 @@
# encodings in all possible combinations.
describe "compatibility matrix" do

=begin
Use the following script to regenerate the matrix:
```
# -*- encoding: binary -*-
ENCODINGS = [
"US-ASCII",
"UTF-8",
"ASCII-8BIT",
"ISO-8859-1", # ASCII-compatible
"UTF-16BE", # non-ASCII-compatible
"ISO-2022-JP" # dummy
]
TYPES = [:empty, :"7bits", :non7bits]
VALUES = {
empty: "",
:"7bits" => "\x01",
non7bits: "\x81"
}
ENCODINGS.product(TYPES, ENCODINGS, TYPES).each do |encoding1, type1, encoding2, type2|
value1 = VALUES[type1].dup.force_encoding(encoding1)
value2 = VALUES[type2].dup.force_encoding(encoding2)
result_encoding = Encoding.compatible?(value1, value2)
puts "[#{encoding1.inspect}, #{value1.inspect}, #{encoding2.inspect}, #{value2.inspect}, #{result_encoding&.name.inspect}],"
end
```
=end
# Use the following script to regenerate the matrix:
#
# ```
# # -*- encoding: binary -*-
#
# ENCODINGS = [
# "US-ASCII",
# "UTF-8",
# "ASCII-8BIT",
# "ISO-8859-1", # ASCII-compatible
# "UTF-16BE", # non-ASCII-compatible
# "ISO-2022-JP" # dummy
# ]
#
# TYPES = [:empty, :"7bits", :non7bits]
#
# VALUES = {
# empty: "",
# :"7bits" => "\x01",
# non7bits: "\x81"
# }
#
# ENCODINGS.product(TYPES, ENCODINGS, TYPES).each do |encoding1, type1, encoding2, type2|
# value1 = VALUES[type1].dup.force_encoding(encoding1)
# value2 = VALUES[type2].dup.force_encoding(encoding2)
#
# result_encoding = Encoding.compatible?(value1, value2)
#
# puts "[#{encoding1.inspect}, #{value1.inspect}, #{encoding2.inspect}, #{value2.inspect}, #{result_encoding&.name.inspect}],"
# end
# ```

matrix = [
["US-ASCII", "", "US-ASCII", "", "US-ASCII"],
Expand Down

0 comments on commit 7723ed9

Please sign in to comment.