diff options
author | Andrew Konchin <[email protected]> | 2024-12-09 20:32:39 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2024-12-10 14:38:52 +0100 |
commit | de5df203bcfb228b7043ae0116535953c325ddb4 (patch) | |
tree | a3b8b89d3010cc554fdb1df2720e81be41357787 /spec/ruby/core | |
parent | a90d8c335a6f5f2ae0c9480c9a546089f52e9028 (diff) |
Update to ruby/spec@9f10222
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12297
Diffstat (limited to 'spec/ruby/core')
21 files changed, 710 insertions, 317 deletions
diff --git a/spec/ruby/core/array/pack/shared/basic.rb b/spec/ruby/core/array/pack/shared/basic.rb index 5e3eea55f9..4b28de7ed0 100644 --- a/spec/ruby/core/array/pack/shared/basic.rb +++ b/spec/ruby/core/array/pack/shared/basic.rb @@ -57,9 +57,9 @@ describe :array_pack_basic_non_float, shared: true do # NOTE: Added this case just to not forget about the decision in the ticket it "raise ArgumentError when a directive is unknown" do # additional directive ('a') is required for the X directive - -> { [@obj, @obj].pack("a R" + pack_format) }.should raise_error(ArgumentError) - -> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError) - -> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError) + -> { [@obj, @obj].pack("a R" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'R'/) + -> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive '0'/) + -> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive ':'/) end end diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb index 745f02d46b..8db74881ba 100644 --- a/spec/ruby/core/dir/shared/glob.rb +++ b/spec/ruby/core/dir/shared/glob.rb @@ -12,7 +12,7 @@ describe :dir_glob, shared: true do end it "raises an Encoding::CompatibilityError if the argument encoding is not compatible with US-ASCII" do - pattern = "file*".dup.force_encoding Encoding::UTF_16BE + pattern = "files*".dup.force_encoding Encoding::UTF_16BE -> { Dir.send(@method, pattern) }.should raise_error(Encoding::CompatibilityError) end diff --git a/spec/ruby/core/encoding/compatible_spec.rb b/spec/ruby/core/encoding/compatible_spec.rb index d5b958ea0b..61a651893b 100644 --- a/spec/ruby/core/encoding/compatible_spec.rb +++ b/spec/ruby/core/encoding/compatible_spec.rb @@ -114,11 +114,11 @@ describe "Encoding.compatible? String, String" do end it "returns nil when the second's Encoding is invalid and ASCII only" do - Encoding.compatible?(@str, "\x7f".dup.force_encoding("utf-16be")).should be_nil + Encoding.compatible?(@str, "\x7f\x7f".dup.force_encoding("utf-16be")).should be_nil end it "returns nil when the second's Encoding is invalid and not ASCII only" do - Encoding.compatible?(@str, "\xff".dup.force_encoding("utf-16be")).should be_nil + Encoding.compatible?(@str, "\xff\xff".dup.force_encoding("utf-16be")).should be_nil end it "returns the Encoding when the second's Encoding is invalid but the same as the first" do @@ -186,8 +186,8 @@ describe "Encoding.compatible? String, String" do # # VALUES = { # empty: "", -# :"7bits" => "\x01", -# non7bits: "\x81" +# :"7bits" => "\x01\x01", +# non7bits: "\x01\x81" # } # # ENCODINGS.product(TYPES, ENCODINGS, TYPES).each do |encoding1, type1, encoding2, type2| @@ -202,329 +202,329 @@ describe "Encoding.compatible? String, String" do matrix = [ ["US-ASCII", "", "US-ASCII", "", "US-ASCII"], - ["US-ASCII", "", "US-ASCII", "\x01", "US-ASCII"], - ["US-ASCII", "", "US-ASCII", "\x81", "US-ASCII"], + ["US-ASCII", "", "US-ASCII", "\x01\x01", "US-ASCII"], + ["US-ASCII", "", "US-ASCII", "\x01\x81", "US-ASCII"], ["US-ASCII", "", "UTF-8", "", "US-ASCII"], - ["US-ASCII", "", "UTF-8", "\u0001", "US-ASCII"], - ["US-ASCII", "", "UTF-8", "\x81", "UTF-8"], + ["US-ASCII", "", "UTF-8", "\u0001\u0001", "US-ASCII"], + ["US-ASCII", "", "UTF-8", "\u0001\x81", "UTF-8"], ["US-ASCII", "", "ASCII-8BIT", "", "US-ASCII"], - ["US-ASCII", "", "ASCII-8BIT", "\x01", "US-ASCII"], - ["US-ASCII", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"], + ["US-ASCII", "", "ASCII-8BIT", "\x01\x01", "US-ASCII"], + ["US-ASCII", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], ["US-ASCII", "", "ISO-8859-1", "", "US-ASCII"], - ["US-ASCII", "", "ISO-8859-1", "\x01", "US-ASCII"], - ["US-ASCII", "", "ISO-8859-1", "\x81", "ISO-8859-1"], + ["US-ASCII", "", "ISO-8859-1", "\x01\x01", "US-ASCII"], + ["US-ASCII", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], ["US-ASCII", "", "UTF-16BE", "", "US-ASCII"], - ["US-ASCII", "", "UTF-16BE", "\x01", "UTF-16BE"], - ["US-ASCII", "", "UTF-16BE", "\x81", "UTF-16BE"], + ["US-ASCII", "", "UTF-16BE", "\u0101", "UTF-16BE"], + ["US-ASCII", "", "UTF-16BE", "\u0181", "UTF-16BE"], ["US-ASCII", "", "ISO-2022-JP", "", "US-ASCII"], - ["US-ASCII", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"], - ["US-ASCII", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"], - ["US-ASCII", "\x01", "US-ASCII", "", "US-ASCII"], - ["US-ASCII", "\x01", "US-ASCII", "\x01", "US-ASCII"], - ["US-ASCII", "\x01", "US-ASCII", "\x81", "US-ASCII"], - ["US-ASCII", "\x01", "UTF-8", "", "US-ASCII"], - ["US-ASCII", "\x01", "UTF-8", "\u0001", "US-ASCII"], - ["US-ASCII", "\x01", "UTF-8", "\x81", "UTF-8"], - ["US-ASCII", "\x01", "ASCII-8BIT", "", "US-ASCII"], - ["US-ASCII", "\x01", "ASCII-8BIT", "\x01", "US-ASCII"], - ["US-ASCII", "\x01", "ASCII-8BIT", "\x81", "ASCII-8BIT"], - ["US-ASCII", "\x01", "ISO-8859-1", "", "US-ASCII"], - ["US-ASCII", "\x01", "ISO-8859-1", "\x01", "US-ASCII"], - ["US-ASCII", "\x01", "ISO-8859-1", "\x81", "ISO-8859-1"], - ["US-ASCII", "\x01", "UTF-16BE", "", "US-ASCII"], - ["US-ASCII", "\x01", "UTF-16BE", "\x01", nil], - ["US-ASCII", "\x01", "UTF-16BE", "\x81", nil], - ["US-ASCII", "\x01", "ISO-2022-JP", "", "US-ASCII"], - ["US-ASCII", "\x01", "ISO-2022-JP", "\x01", nil], - ["US-ASCII", "\x01", "ISO-2022-JP", "\x81", nil], - ["US-ASCII", "\x81", "US-ASCII", "", "US-ASCII"], - ["US-ASCII", "\x81", "US-ASCII", "\x01", "US-ASCII"], - ["US-ASCII", "\x81", "US-ASCII", "\x81", "US-ASCII"], - ["US-ASCII", "\x81", "UTF-8", "", "US-ASCII"], - ["US-ASCII", "\x81", "UTF-8", "\u0001", "US-ASCII"], - ["US-ASCII", "\x81", "UTF-8", "\x81", nil], - ["US-ASCII", "\x81", "ASCII-8BIT", "", "US-ASCII"], - ["US-ASCII", "\x81", "ASCII-8BIT", "\x01", "US-ASCII"], - ["US-ASCII", "\x81", "ASCII-8BIT", "\x81", nil], - ["US-ASCII", "\x81", "ISO-8859-1", "", "US-ASCII"], - ["US-ASCII", "\x81", "ISO-8859-1", "\x01", "US-ASCII"], - ["US-ASCII", "\x81", "ISO-8859-1", "\x81", nil], - ["US-ASCII", "\x81", "UTF-16BE", "", "US-ASCII"], - ["US-ASCII", "\x81", "UTF-16BE", "\x01", nil], - ["US-ASCII", "\x81", "UTF-16BE", "\x81", nil], - ["US-ASCII", "\x81", "ISO-2022-JP", "", "US-ASCII"], - ["US-ASCII", "\x81", "ISO-2022-JP", "\x01", nil], - ["US-ASCII", "\x81", "ISO-2022-JP", "\x81", nil], + ["US-ASCII", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"], + ["US-ASCII", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"], + ["US-ASCII", "\x01\x01", "US-ASCII", "", "US-ASCII"], + ["US-ASCII", "\x01\x01", "US-ASCII", "\x01\x01", "US-ASCII"], + ["US-ASCII", "\x01\x01", "US-ASCII", "\x01\x81", "US-ASCII"], + ["US-ASCII", "\x01\x01", "UTF-8", "", "US-ASCII"], + ["US-ASCII", "\x01\x01", "UTF-8", "\u0001\u0001", "US-ASCII"], + ["US-ASCII", "\x01\x01", "UTF-8", "\u0001\x81", "UTF-8"], + ["US-ASCII", "\x01\x01", "ASCII-8BIT", "", "US-ASCII"], + ["US-ASCII", "\x01\x01", "ASCII-8BIT", "\x01\x01", "US-ASCII"], + ["US-ASCII", "\x01\x01", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], + ["US-ASCII", "\x01\x01", "ISO-8859-1", "", "US-ASCII"], + ["US-ASCII", "\x01\x01", "ISO-8859-1", "\x01\x01", "US-ASCII"], + ["US-ASCII", "\x01\x01", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], + ["US-ASCII", "\x01\x01", "UTF-16BE", "", "US-ASCII"], + ["US-ASCII", "\x01\x01", "UTF-16BE", "\u0101", nil], + ["US-ASCII", "\x01\x01", "UTF-16BE", "\u0181", nil], + ["US-ASCII", "\x01\x01", "ISO-2022-JP", "", "US-ASCII"], + ["US-ASCII", "\x01\x01", "ISO-2022-JP", "\x01\x01", nil], + ["US-ASCII", "\x01\x01", "ISO-2022-JP", "\x01\x81", nil], + ["US-ASCII", "\x01\x81", "US-ASCII", "", "US-ASCII"], + ["US-ASCII", "\x01\x81", "US-ASCII", "\x01\x01", "US-ASCII"], + ["US-ASCII", "\x01\x81", "US-ASCII", "\x01\x81", "US-ASCII"], + ["US-ASCII", "\x01\x81", "UTF-8", "", "US-ASCII"], + ["US-ASCII", "\x01\x81", "UTF-8", "\u0001\u0001", "US-ASCII"], + ["US-ASCII", "\x01\x81", "UTF-8", "\u0001\x81", nil], + ["US-ASCII", "\x01\x81", "ASCII-8BIT", "", "US-ASCII"], + ["US-ASCII", "\x01\x81", "ASCII-8BIT", "\x01\x01", "US-ASCII"], + ["US-ASCII", "\x01\x81", "ASCII-8BIT", "\x01\x81", nil], + ["US-ASCII", "\x01\x81", "ISO-8859-1", "", "US-ASCII"], + ["US-ASCII", "\x01\x81", "ISO-8859-1", "\x01\x01", "US-ASCII"], + ["US-ASCII", "\x01\x81", "ISO-8859-1", "\x01\x81", nil], + ["US-ASCII", "\x01\x81", "UTF-16BE", "", "US-ASCII"], + ["US-ASCII", "\x01\x81", "UTF-16BE", "\u0101", nil], + ["US-ASCII", "\x01\x81", "UTF-16BE", "\u0181", nil], + ["US-ASCII", "\x01\x81", "ISO-2022-JP", "", "US-ASCII"], + ["US-ASCII", "\x01\x81", "ISO-2022-JP", "\x01\x01", nil], + ["US-ASCII", "\x01\x81", "ISO-2022-JP", "\x01\x81", nil], ["UTF-8", "", "US-ASCII", "", "UTF-8"], - ["UTF-8", "", "US-ASCII", "\x01", "UTF-8"], - ["UTF-8", "", "US-ASCII", "\x81", "US-ASCII"], + ["UTF-8", "", "US-ASCII", "\x01\x01", "UTF-8"], + ["UTF-8", "", "US-ASCII", "\x01\x81", "US-ASCII"], ["UTF-8", "", "UTF-8", "", "UTF-8"], - ["UTF-8", "", "UTF-8", "\u0001", "UTF-8"], - ["UTF-8", "", "UTF-8", "\x81", "UTF-8"], + ["UTF-8", "", "UTF-8", "\u0001\u0001", "UTF-8"], + ["UTF-8", "", "UTF-8", "\u0001\x81", "UTF-8"], ["UTF-8", "", "ASCII-8BIT", "", "UTF-8"], - ["UTF-8", "", "ASCII-8BIT", "\x01", "UTF-8"], - ["UTF-8", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"], + ["UTF-8", "", "ASCII-8BIT", "\x01\x01", "UTF-8"], + ["UTF-8", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], ["UTF-8", "", "ISO-8859-1", "", "UTF-8"], - ["UTF-8", "", "ISO-8859-1", "\x01", "UTF-8"], - ["UTF-8", "", "ISO-8859-1", "\x81", "ISO-8859-1"], + ["UTF-8", "", "ISO-8859-1", "\x01\x01", "UTF-8"], + ["UTF-8", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], ["UTF-8", "", "UTF-16BE", "", "UTF-8"], - ["UTF-8", "", "UTF-16BE", "\x01", "UTF-16BE"], - ["UTF-8", "", "UTF-16BE", "\x81", "UTF-16BE"], + ["UTF-8", "", "UTF-16BE", "\u0101", "UTF-16BE"], + ["UTF-8", "", "UTF-16BE", "\u0181", "UTF-16BE"], ["UTF-8", "", "ISO-2022-JP", "", "UTF-8"], - ["UTF-8", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"], - ["UTF-8", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"], - ["UTF-8", "\u0001", "US-ASCII", "", "UTF-8"], - ["UTF-8", "\u0001", "US-ASCII", "\x01", "UTF-8"], - ["UTF-8", "\u0001", "US-ASCII", "\x81", "US-ASCII"], - ["UTF-8", "\u0001", "UTF-8", "", "UTF-8"], - ["UTF-8", "\u0001", "UTF-8", "\u0001", "UTF-8"], - ["UTF-8", "\u0001", "UTF-8", "\x81", "UTF-8"], - ["UTF-8", "\u0001", "ASCII-8BIT", "", "UTF-8"], - ["UTF-8", "\u0001", "ASCII-8BIT", "\x01", "UTF-8"], - ["UTF-8", "\u0001", "ASCII-8BIT", "\x81", "ASCII-8BIT"], - ["UTF-8", "\u0001", "ISO-8859-1", "", "UTF-8"], - ["UTF-8", "\u0001", "ISO-8859-1", "\x01", "UTF-8"], - ["UTF-8", "\u0001", "ISO-8859-1", "\x81", "ISO-8859-1"], - ["UTF-8", "\u0001", "UTF-16BE", "", "UTF-8"], - ["UTF-8", "\u0001", "UTF-16BE", "\x01", nil], - ["UTF-8", "\u0001", "UTF-16BE", "\x81", nil], - ["UTF-8", "\u0001", "ISO-2022-JP", "", "UTF-8"], - ["UTF-8", "\u0001", "ISO-2022-JP", "\x01", nil], - ["UTF-8", "\u0001", "ISO-2022-JP", "\x81", nil], - ["UTF-8", "\x81", "US-ASCII", "", "UTF-8"], - ["UTF-8", "\x81", "US-ASCII", "\x01", "UTF-8"], - ["UTF-8", "\x81", "US-ASCII", "\x81", nil], - ["UTF-8", "\x81", "UTF-8", "", "UTF-8"], - ["UTF-8", "\x81", "UTF-8", "\u0001", "UTF-8"], - ["UTF-8", "\x81", "UTF-8", "\x81", "UTF-8"], - ["UTF-8", "\x81", "ASCII-8BIT", "", "UTF-8"], - ["UTF-8", "\x81", "ASCII-8BIT", "\x01", "UTF-8"], - ["UTF-8", "\x81", "ASCII-8BIT", "\x81", nil], - ["UTF-8", "\x81", "ISO-8859-1", "", "UTF-8"], - ["UTF-8", "\x81", "ISO-8859-1", "\x01", "UTF-8"], - ["UTF-8", "\x81", "ISO-8859-1", "\x81", nil], - ["UTF-8", "\x81", "UTF-16BE", "", "UTF-8"], - ["UTF-8", "\x81", "UTF-16BE", "\x01", nil], - ["UTF-8", "\x81", "UTF-16BE", "\x81", nil], - ["UTF-8", "\x81", "ISO-2022-JP", "", "UTF-8"], - ["UTF-8", "\x81", "ISO-2022-JP", "\x01", nil], - ["UTF-8", "\x81", "ISO-2022-JP", "\x81", nil], + ["UTF-8", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"], + ["UTF-8", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"], + ["UTF-8", "\u0001\u0001", "US-ASCII", "", "UTF-8"], + ["UTF-8", "\u0001\u0001", "US-ASCII", "\x01\x01", "UTF-8"], + ["UTF-8", "\u0001\u0001", "US-ASCII", "\x01\x81", "US-ASCII"], + ["UTF-8", "\u0001\u0001", "UTF-8", "", "UTF-8"], + ["UTF-8", "\u0001\u0001", "UTF-8", "\u0001\u0001", "UTF-8"], + ["UTF-8", "\u0001\u0001", "UTF-8", "\u0001\x81", "UTF-8"], + ["UTF-8", "\u0001\u0001", "ASCII-8BIT", "", "UTF-8"], + ["UTF-8", "\u0001\u0001", "ASCII-8BIT", "\x01\x01", "UTF-8"], + ["UTF-8", "\u0001\u0001", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], + ["UTF-8", "\u0001\u0001", "ISO-8859-1", "", "UTF-8"], + ["UTF-8", "\u0001\u0001", "ISO-8859-1", "\x01\x01", "UTF-8"], + ["UTF-8", "\u0001\u0001", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], + ["UTF-8", "\u0001\u0001", "UTF-16BE", "", "UTF-8"], + ["UTF-8", "\u0001\u0001", "UTF-16BE", "\u0101", nil], + ["UTF-8", "\u0001\u0001", "UTF-16BE", "\u0181", nil], + ["UTF-8", "\u0001\u0001", "ISO-2022-JP", "", "UTF-8"], + ["UTF-8", "\u0001\u0001", "ISO-2022-JP", "\x01\x01", nil], + ["UTF-8", "\u0001\u0001", "ISO-2022-JP", "\x01\x81", nil], + ["UTF-8", "\u0001\x81", "US-ASCII", "", "UTF-8"], + ["UTF-8", "\u0001\x81", "US-ASCII", "\x01\x01", "UTF-8"], + ["UTF-8", "\u0001\x81", "US-ASCII", "\x01\x81", nil], + ["UTF-8", "\u0001\x81", "UTF-8", "", "UTF-8"], + ["UTF-8", "\u0001\x81", "UTF-8", "\u0001\u0001", "UTF-8"], + ["UTF-8", "\u0001\x81", "UTF-8", "\u0001\x81", "UTF-8"], + ["UTF-8", "\u0001\x81", "ASCII-8BIT", "", "UTF-8"], + ["UTF-8", "\u0001\x81", "ASCII-8BIT", "\x01\x01", "UTF-8"], + ["UTF-8", "\u0001\x81", "ASCII-8BIT", "\x01\x81", nil], + ["UTF-8", "\u0001\x81", "ISO-8859-1", "", "UTF-8"], + ["UTF-8", "\u0001\x81", "ISO-8859-1", "\x01\x01", "UTF-8"], + ["UTF-8", "\u0001\x81", "ISO-8859-1", "\x01\x81", nil], + ["UTF-8", "\u0001\x81", "UTF-16BE", "", "UTF-8"], + ["UTF-8", "\u0001\x81", "UTF-16BE", "\u0101", nil], + ["UTF-8", "\u0001\x81", "UTF-16BE", "\u0181", nil], + ["UTF-8", "\u0001\x81", "ISO-2022-JP", "", "UTF-8"], + ["UTF-8", "\u0001\x81", "ISO-2022-JP", "\x01\x01", nil], + ["UTF-8", "\u0001\x81", "ISO-2022-JP", "\x01\x81", nil], ["ASCII-8BIT", "", "US-ASCII", "", "ASCII-8BIT"], - ["ASCII-8BIT", "", "US-ASCII", "\x01", "ASCII-8BIT"], - ["ASCII-8BIT", "", "US-ASCII", "\x81", "US-ASCII"], + ["ASCII-8BIT", "", "US-ASCII", "\x01\x01", "ASCII-8BIT"], + ["ASCII-8BIT", "", "US-ASCII", "\x01\x81", "US-ASCII"], ["ASCII-8BIT", "", "UTF-8", "", "ASCII-8BIT"], - ["ASCII-8BIT", "", "UTF-8", "\u0001", "ASCII-8BIT"], - ["ASCII-8BIT", "", "UTF-8", "\x81", "UTF-8"], + ["ASCII-8BIT", "", "UTF-8", "\u0001\u0001", "ASCII-8BIT"], + ["ASCII-8BIT", "", "UTF-8", "\u0001\x81", "UTF-8"], ["ASCII-8BIT", "", "ASCII-8BIT", "", "ASCII-8BIT"], - ["ASCII-8BIT", "", "ASCII-8BIT", "\x01", "ASCII-8BIT"], - ["ASCII-8BIT", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"], + ["ASCII-8BIT", "", "ASCII-8BIT", "\x01\x01", "ASCII-8BIT"], + ["ASCII-8BIT", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], ["ASCII-8BIT", "", "ISO-8859-1", "", "ASCII-8BIT"], - ["ASCII-8BIT", "", "ISO-8859-1", "\x01", "ASCII-8BIT"], - ["ASCII-8BIT", "", "ISO-8859-1", "\x81", "ISO-8859-1"], + ["ASCII-8BIT", "", "ISO-8859-1", "\x01\x01", "ASCII-8BIT"], + ["ASCII-8BIT", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], ["ASCII-8BIT", "", "UTF-16BE", "", "ASCII-8BIT"], - ["ASCII-8BIT", "", "UTF-16BE", "\x01", "UTF-16BE"], - ["ASCII-8BIT", "", "UTF-16BE", "\x81", "UTF-16BE"], + ["ASCII-8BIT", "", "UTF-16BE", "\u0101", "UTF-16BE"], + ["ASCII-8BIT", "", "UTF-16BE", "\u0181", "UTF-16BE"], ["ASCII-8BIT", "", "ISO-2022-JP", "", "ASCII-8BIT"], - ["ASCII-8BIT", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"], - ["ASCII-8BIT", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"], - ["ASCII-8BIT", "\x01", "US-ASCII", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "US-ASCII", "\x01", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "US-ASCII", "\x81", "US-ASCII"], - ["ASCII-8BIT", "\x01", "UTF-8", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "UTF-8", "\u0001", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "UTF-8", "\x81", "UTF-8"], - ["ASCII-8BIT", "\x01", "ASCII-8BIT", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "ASCII-8BIT", "\x01", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "ASCII-8BIT", "\x81", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "ISO-8859-1", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "ISO-8859-1", "\x01", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "ISO-8859-1", "\x81", "ISO-8859-1"], - ["ASCII-8BIT", "\x01", "UTF-16BE", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "UTF-16BE", "\x01", nil], - ["ASCII-8BIT", "\x01", "UTF-16BE", "\x81", nil], - ["ASCII-8BIT", "\x01", "ISO-2022-JP", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x01", "ISO-2022-JP", "\x01", nil], - ["ASCII-8BIT", "\x01", "ISO-2022-JP", "\x81", nil], - ["ASCII-8BIT", "\x81", "US-ASCII", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "US-ASCII", "\x01", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "US-ASCII", "\x81", nil], - ["ASCII-8BIT", "\x81", "UTF-8", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "UTF-8", "\u0001", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "UTF-8", "\x81", nil], - ["ASCII-8BIT", "\x81", "ASCII-8BIT", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "ASCII-8BIT", "\x01", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "ASCII-8BIT", "\x81", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "ISO-8859-1", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "ISO-8859-1", "\x01", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "ISO-8859-1", "\x81", nil], - ["ASCII-8BIT", "\x81", "UTF-16BE", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "UTF-16BE", "\x01", nil], - ["ASCII-8BIT", "\x81", "UTF-16BE", "\x81", nil], - ["ASCII-8BIT", "\x81", "ISO-2022-JP", "", "ASCII-8BIT"], - ["ASCII-8BIT", "\x81", "ISO-2022-JP", "\x01", nil], - ["ASCII-8BIT", "\x81", "ISO-2022-JP", "\x81", nil], + ["ASCII-8BIT", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"], + ["ASCII-8BIT", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"], + ["ASCII-8BIT", "\x01\x01", "US-ASCII", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "US-ASCII", "\x01\x01", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "US-ASCII", "\x01\x81", "US-ASCII"], + ["ASCII-8BIT", "\x01\x01", "UTF-8", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "UTF-8", "\u0001\u0001", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "UTF-8", "\u0001\x81", "UTF-8"], + ["ASCII-8BIT", "\x01\x01", "ASCII-8BIT", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "ASCII-8BIT", "\x01\x01", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "ISO-8859-1", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "ISO-8859-1", "\x01\x01", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], + ["ASCII-8BIT", "\x01\x01", "UTF-16BE", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "UTF-16BE", "\u0101", nil], + ["ASCII-8BIT", "\x01\x01", "UTF-16BE", "\u0181", nil], + ["ASCII-8BIT", "\x01\x01", "ISO-2022-JP", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x01", "ISO-2022-JP", "\x01\x01", nil], + ["ASCII-8BIT", "\x01\x01", "ISO-2022-JP", "\x01\x81", nil], + ["ASCII-8BIT", "\x01\x81", "US-ASCII", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "US-ASCII", "\x01\x01", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "US-ASCII", "\x01\x81", nil], + ["ASCII-8BIT", "\x01\x81", "UTF-8", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "UTF-8", "\u0001\u0001", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "UTF-8", "\u0001\x81", nil], + ["ASCII-8BIT", "\x01\x81", "ASCII-8BIT", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "ASCII-8BIT", "\x01\x01", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "ISO-8859-1", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "ISO-8859-1", "\x01\x01", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "ISO-8859-1", "\x01\x81", nil], + ["ASCII-8BIT", "\x01\x81", "UTF-16BE", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "UTF-16BE", "\u0101", nil], + ["ASCII-8BIT", "\x01\x81", "UTF-16BE", "\u0181", nil], + ["ASCII-8BIT", "\x01\x81", "ISO-2022-JP", "", "ASCII-8BIT"], + ["ASCII-8BIT", "\x01\x81", "ISO-2022-JP", "\x01\x01", nil], + ["ASCII-8BIT", "\x01\x81", "ISO-2022-JP", "\x01\x81", nil], ["ISO-8859-1", "", "US-ASCII", "", "ISO-8859-1"], - ["ISO-8859-1", "", "US-ASCII", "\x01", "ISO-8859-1"], - ["ISO-8859-1", "", "US-ASCII", "\x81", "US-ASCII"], + ["ISO-8859-1", "", "US-ASCII", "\x01\x01", "ISO-8859-1"], + ["ISO-8859-1", "", "US-ASCII", "\x01\x81", "US-ASCII"], ["ISO-8859-1", "", "UTF-8", "", "ISO-8859-1"], - ["ISO-8859-1", "", "UTF-8", "\u0001", "ISO-8859-1"], - ["ISO-8859-1", "", "UTF-8", "\x81", "UTF-8"], + ["ISO-8859-1", "", "UTF-8", "\u0001\u0001", "ISO-8859-1"], + ["ISO-8859-1", "", "UTF-8", "\u0001\x81", "UTF-8"], ["ISO-8859-1", "", "ASCII-8BIT", "", "ISO-8859-1"], - ["ISO-8859-1", "", "ASCII-8BIT", "\x01", "ISO-8859-1"], - ["ISO-8859-1", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"], + ["ISO-8859-1", "", "ASCII-8BIT", "\x01\x01", "ISO-8859-1"], + ["ISO-8859-1", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], ["ISO-8859-1", "", "ISO-8859-1", "", "ISO-8859-1"], - ["ISO-8859-1", "", "ISO-8859-1", "\x01", "ISO-8859-1"], - ["ISO-8859-1", "", "ISO-8859-1", "\x81", "ISO-8859-1"], + ["ISO-8859-1", "", "ISO-8859-1", "\x01\x01", "ISO-8859-1"], + ["ISO-8859-1", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], ["ISO-8859-1", "", "UTF-16BE", "", "ISO-8859-1"], - ["ISO-8859-1", "", "UTF-16BE", "\x01", "UTF-16BE"], - ["ISO-8859-1", "", "UTF-16BE", "\x81", "UTF-16BE"], + ["ISO-8859-1", "", "UTF-16BE", "\u0101", "UTF-16BE"], + ["ISO-8859-1", "", "UTF-16BE", "\u0181", "UTF-16BE"], ["ISO-8859-1", "", "ISO-2022-JP", "", "ISO-8859-1"], - ["ISO-8859-1", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"], - ["ISO-8859-1", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"], - ["ISO-8859-1", "\x01", "US-ASCII", "", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "US-ASCII", "\x01", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "US-ASCII", "\x81", "US-ASCII"], - ["ISO-8859-1", "\x01", "UTF-8", "", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "UTF-8", "\u0001", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "UTF-8", "\x81", "UTF-8"], - ["ISO-8859-1", "\x01", "ASCII-8BIT", "", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "ASCII-8BIT", "\x01", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "ASCII-8BIT", "\x81", "ASCII-8BIT"], - ["ISO-8859-1", "\x01", "ISO-8859-1", "", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "ISO-8859-1", "\x01", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "ISO-8859-1", "\x81", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "UTF-16BE", "", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "UTF-16BE", "\x01", nil], - ["ISO-8859-1", "\x01", "UTF-16BE", "\x81", nil], - ["ISO-8859-1", "\x01", "ISO-2022-JP", "", "ISO-8859-1"], - ["ISO-8859-1", "\x01", "ISO-2022-JP", "\x01", nil], - ["ISO-8859-1", "\x01", "ISO-2022-JP", "\x81", nil], - ["ISO-8859-1", "\x81", "US-ASCII", "", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "US-ASCII", "\x01", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "US-ASCII", "\x81", nil], - ["ISO-8859-1", "\x81", "UTF-8", "", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "UTF-8", "\u0001", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "UTF-8", "\x81", nil], - ["ISO-8859-1", "\x81", "ASCII-8BIT", "", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "ASCII-8BIT", "\x01", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "ASCII-8BIT", "\x81", nil], - ["ISO-8859-1", "\x81", "ISO-8859-1", "", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "ISO-8859-1", "\x01", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "ISO-8859-1", "\x81", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "UTF-16BE", "", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "UTF-16BE", "\x01", nil], - ["ISO-8859-1", "\x81", "UTF-16BE", "\x81", nil], - ["ISO-8859-1", "\x81", "ISO-2022-JP", "", "ISO-8859-1"], - ["ISO-8859-1", "\x81", "ISO-2022-JP", "\x01", nil], - ["ISO-8859-1", "\x81", "ISO-2022-JP", "\x81", nil], + ["ISO-8859-1", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"], + ["ISO-8859-1", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"], + ["ISO-8859-1", "\x01\x01", "US-ASCII", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "US-ASCII", "\x01\x01", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "US-ASCII", "\x01\x81", "US-ASCII"], + ["ISO-8859-1", "\x01\x01", "UTF-8", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "UTF-8", "\u0001\u0001", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "UTF-8", "\u0001\x81", "UTF-8"], + ["ISO-8859-1", "\x01\x01", "ASCII-8BIT", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "ASCII-8BIT", "\x01\x01", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], + ["ISO-8859-1", "\x01\x01", "ISO-8859-1", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "ISO-8859-1", "\x01\x01", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "UTF-16BE", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "UTF-16BE", "\u0101", nil], + ["ISO-8859-1", "\x01\x01", "UTF-16BE", "\u0181", nil], + ["ISO-8859-1", "\x01\x01", "ISO-2022-JP", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x01", "ISO-2022-JP", "\x01\x01", nil], + ["ISO-8859-1", "\x01\x01", "ISO-2022-JP", "\x01\x81", nil], + ["ISO-8859-1", "\x01\x81", "US-ASCII", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "US-ASCII", "\x01\x01", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "US-ASCII", "\x01\x81", nil], + ["ISO-8859-1", "\x01\x81", "UTF-8", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "UTF-8", "\u0001\u0001", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "UTF-8", "\u0001\x81", nil], + ["ISO-8859-1", "\x01\x81", "ASCII-8BIT", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "ASCII-8BIT", "\x01\x01", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "ASCII-8BIT", "\x01\x81", nil], + ["ISO-8859-1", "\x01\x81", "ISO-8859-1", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "ISO-8859-1", "\x01\x01", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "UTF-16BE", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "UTF-16BE", "\u0101", nil], + ["ISO-8859-1", "\x01\x81", "UTF-16BE", "\u0181", nil], + ["ISO-8859-1", "\x01\x81", "ISO-2022-JP", "", "ISO-8859-1"], + ["ISO-8859-1", "\x01\x81", "ISO-2022-JP", "\x01\x01", nil], + ["ISO-8859-1", "\x01\x81", "ISO-2022-JP", "\x01\x81", nil], ["UTF-16BE", "", "US-ASCII", "", "UTF-16BE"], - ["UTF-16BE", "", "US-ASCII", "\x01", "US-ASCII"], - ["UTF-16BE", "", "US-ASCII", "\x81", "US-ASCII"], + ["UTF-16BE", "", "US-ASCII", "\x01\x01", "US-ASCII"], + ["UTF-16BE", "", "US-ASCII", "\x01\x81", "US-ASCII"], ["UTF-16BE", "", "UTF-8", "", "UTF-16BE"], - ["UTF-16BE", "", "UTF-8", "\u0001", "UTF-8"], - ["UTF-16BE", "", "UTF-8", "\x81", "UTF-8"], + ["UTF-16BE", "", "UTF-8", "\u0001\u0001", "UTF-8"], + ["UTF-16BE", "", "UTF-8", "\u0001\x81", "UTF-8"], ["UTF-16BE", "", "ASCII-8BIT", "", "UTF-16BE"], - ["UTF-16BE", "", "ASCII-8BIT", "\x01", "ASCII-8BIT"], - ["UTF-16BE", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"], + ["UTF-16BE", "", "ASCII-8BIT", "\x01\x01", "ASCII-8BIT"], + ["UTF-16BE", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], ["UTF-16BE", "", "ISO-8859-1", "", "UTF-16BE"], - ["UTF-16BE", "", "ISO-8859-1", "\x01", "ISO-8859-1"], - ["UTF-16BE", "", "ISO-8859-1", "\x81", "ISO-8859-1"], + ["UTF-16BE", "", "ISO-8859-1", "\x01\x01", "ISO-8859-1"], + ["UTF-16BE", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], ["UTF-16BE", "", "UTF-16BE", "", "UTF-16BE"], - ["UTF-16BE", "", "UTF-16BE", "\x01", "UTF-16BE"], - ["UTF-16BE", "", "UTF-16BE", "\x81", "UTF-16BE"], + ["UTF-16BE", "", "UTF-16BE", "\u0101", "UTF-16BE"], + ["UTF-16BE", "", "UTF-16BE", "\u0181", "UTF-16BE"], ["UTF-16BE", "", "ISO-2022-JP", "", "UTF-16BE"], - ["UTF-16BE", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"], - ["UTF-16BE", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"], - ["UTF-16BE", "\x01", "US-ASCII", "", "UTF-16BE"], - ["UTF-16BE", "\x01", "US-ASCII", "\x01", nil], - ["UTF-16BE", "\x01", "US-ASCII", "\x81", nil], - ["UTF-16BE", "\x01", "UTF-8", "", "UTF-16BE"], - ["UTF-16BE", "\x01", "UTF-8", "\u0001", nil], - ["UTF-16BE", "\x01", "UTF-8", "\x81", nil], - ["UTF-16BE", "\x01", "ASCII-8BIT", "", "UTF-16BE"], - ["UTF-16BE", "\x01", "ASCII-8BIT", "\x01", nil], - ["UTF-16BE", "\x01", "ASCII-8BIT", "\x81", nil], - ["UTF-16BE", "\x01", "ISO-8859-1", "", "UTF-16BE"], - ["UTF-16BE", "\x01", "ISO-8859-1", "\x01", nil], - ["UTF-16BE", "\x01", "ISO-8859-1", "\x81", nil], - ["UTF-16BE", "\x01", "UTF-16BE", "", "UTF-16BE"], - ["UTF-16BE", "\x01", "UTF-16BE", "\x01", "UTF-16BE"], - ["UTF-16BE", "\x01", "UTF-16BE", "\x81", "UTF-16BE"], - ["UTF-16BE", "\x01", "ISO-2022-JP", "", "UTF-16BE"], - ["UTF-16BE", "\x01", "ISO-2022-JP", "\x01", nil], - ["UTF-16BE", "\x01", "ISO-2022-JP", "\x81", nil], - ["UTF-16BE", "\x81", "US-ASCII", "", "UTF-16BE"], - ["UTF-16BE", "\x81", "US-ASCII", "\x01", nil], - ["UTF-16BE", "\x81", "US-ASCII", "\x81", nil], - ["UTF-16BE", "\x81", "UTF-8", "", "UTF-16BE"], - ["UTF-16BE", "\x81", "UTF-8", "\u0001", nil], - ["UTF-16BE", "\x81", "UTF-8", "\x81", nil], - ["UTF-16BE", "\x81", "ASCII-8BIT", "", "UTF-16BE"], - ["UTF-16BE", "\x81", "ASCII-8BIT", "\x01", nil], - ["UTF-16BE", "\x81", "ASCII-8BIT", "\x81", nil], - ["UTF-16BE", "\x81", "ISO-8859-1", "", "UTF-16BE"], - ["UTF-16BE", "\x81", "ISO-8859-1", "\x01", nil], - ["UTF-16BE", "\x81", "ISO-8859-1", "\x81", nil], - ["UTF-16BE", "\x81", "UTF-16BE", "", "UTF-16BE"], - ["UTF-16BE", "\x81", "UTF-16BE", "\x01", "UTF-16BE"], - ["UTF-16BE", "\x81", "UTF-16BE", "\x81", "UTF-16BE"], - ["UTF-16BE", "\x81", "ISO-2022-JP", "", "UTF-16BE"], - ["UTF-16BE", "\x81", "ISO-2022-JP", "\x01", nil], - ["UTF-16BE", "\x81", "ISO-2022-JP", "\x81", nil], + ["UTF-16BE", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"], + ["UTF-16BE", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"], + ["UTF-16BE", "\u0101", "US-ASCII", "", "UTF-16BE"], + ["UTF-16BE", "\u0101", "US-ASCII", "\x01\x01", nil], + ["UTF-16BE", "\u0101", "US-ASCII", "\x01\x81", nil], + ["UTF-16BE", "\u0101", "UTF-8", "", "UTF-16BE"], + ["UTF-16BE", "\u0101", "UTF-8", "\u0001\u0001", nil], + ["UTF-16BE", "\u0101", "UTF-8", "\u0001\x81", nil], + ["UTF-16BE", "\u0101", "ASCII-8BIT", "", "UTF-16BE"], + ["UTF-16BE", "\u0101", "ASCII-8BIT", "\x01\x01", nil], + ["UTF-16BE", "\u0101", "ASCII-8BIT", "\x01\x81", nil], + ["UTF-16BE", "\u0101", "ISO-8859-1", "", "UTF-16BE"], + ["UTF-16BE", "\u0101", "ISO-8859-1", "\x01\x01", nil], + ["UTF-16BE", "\u0101", "ISO-8859-1", "\x01\x81", nil], + ["UTF-16BE", "\u0101", "UTF-16BE", "", "UTF-16BE"], + ["UTF-16BE", "\u0101", "UTF-16BE", "\u0101", "UTF-16BE"], + ["UTF-16BE", "\u0101", "UTF-16BE", "\u0181", "UTF-16BE"], + ["UTF-16BE", "\u0101", "ISO-2022-JP", "", "UTF-16BE"], + ["UTF-16BE", "\u0101", "ISO-2022-JP", "\x01\x01", nil], + ["UTF-16BE", "\u0101", "ISO-2022-JP", "\x01\x81", nil], + ["UTF-16BE", "\u0181", "US-ASCII", "", "UTF-16BE"], + ["UTF-16BE", "\u0181", "US-ASCII", "\x01\x01", nil], + ["UTF-16BE", "\u0181", "US-ASCII", "\x01\x81", nil], + ["UTF-16BE", "\u0181", "UTF-8", "", "UTF-16BE"], + ["UTF-16BE", "\u0181", "UTF-8", "\u0001\u0001", nil], + ["UTF-16BE", "\u0181", "UTF-8", "\u0001\x81", nil], + ["UTF-16BE", "\u0181", "ASCII-8BIT", "", "UTF-16BE"], + ["UTF-16BE", "\u0181", "ASCII-8BIT", "\x01\x01", nil], + ["UTF-16BE", "\u0181", "ASCII-8BIT", "\x01\x81", nil], + ["UTF-16BE", "\u0181", "ISO-8859-1", "", "UTF-16BE"], + ["UTF-16BE", "\u0181", "ISO-8859-1", "\x01\x01", nil], + ["UTF-16BE", "\u0181", "ISO-8859-1", "\x01\x81", nil], + ["UTF-16BE", "\u0181", "UTF-16BE", "", "UTF-16BE"], + ["UTF-16BE", "\u0181", "UTF-16BE", "\u0101", "UTF-16BE"], + ["UTF-16BE", "\u0181", "UTF-16BE", "\u0181", "UTF-16BE"], + ["UTF-16BE", "\u0181", "ISO-2022-JP", "", "UTF-16BE"], + ["UTF-16BE", "\u0181", "ISO-2022-JP", "\x01\x01", nil], + ["UTF-16BE", "\u0181", "ISO-2022-JP", "\x01\x81", nil], ["ISO-2022-JP", "", "US-ASCII", "", "ISO-2022-JP"], - ["ISO-2022-JP", "", "US-ASCII", "\x01", "US-ASCII"], - ["ISO-2022-JP", "", "US-ASCII", "\x81", "US-ASCII"], + ["ISO-2022-JP", "", "US-ASCII", "\x01\x01", "US-ASCII"], + ["ISO-2022-JP", "", "US-ASCII", "\x01\x81", "US-ASCII"], ["ISO-2022-JP", "", "UTF-8", "", "ISO-2022-JP"], - ["ISO-2022-JP", "", "UTF-8", "\u0001", "UTF-8"], - ["ISO-2022-JP", "", "UTF-8", "\x81", "UTF-8"], + ["ISO-2022-JP", "", "UTF-8", "\u0001\u0001", "UTF-8"], + ["ISO-2022-JP", "", "UTF-8", "\u0001\x81", "UTF-8"], ["ISO-2022-JP", "", "ASCII-8BIT", "", "ISO-2022-JP"], - ["ISO-2022-JP", "", "ASCII-8BIT", "\x01", "ASCII-8BIT"], - ["ISO-2022-JP", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"], + ["ISO-2022-JP", "", "ASCII-8BIT", "\x01\x01", "ASCII-8BIT"], + ["ISO-2022-JP", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"], ["ISO-2022-JP", "", "ISO-8859-1", "", "ISO-2022-JP"], - ["ISO-2022-JP", "", "ISO-8859-1", "\x01", "ISO-8859-1"], - ["ISO-2022-JP", "", "ISO-8859-1", "\x81", "ISO-8859-1"], + ["ISO-2022-JP", "", "ISO-8859-1", "\x01\x01", "ISO-8859-1"], + ["ISO-2022-JP", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"], ["ISO-2022-JP", "", "UTF-16BE", "", "ISO-2022-JP"], - ["ISO-2022-JP", "", "UTF-16BE", "\x01", "UTF-16BE"], - ["ISO-2022-JP", "", "UTF-16BE", "\x81", "UTF-16BE"], + ["ISO-2022-JP", "", "UTF-16BE", "\u0101", "UTF-16BE"], + ["ISO-2022-JP", "", "UTF-16BE", "\u0181", "UTF-16BE"], ["ISO-2022-JP", "", "ISO-2022-JP", "", "ISO-2022-JP"], - ["ISO-2022-JP", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"], - ["ISO-2022-JP", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"], - ["ISO-2022-JP", "\x01", "US-ASCII", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x01", "US-ASCII", "\x01", nil], - ["ISO-2022-JP", "\x01", "US-ASCII", "\x81", nil], - ["ISO-2022-JP", "\x01", "UTF-8", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x01", "UTF-8", "\u0001", nil], - ["ISO-2022-JP", "\x01", "UTF-8", "\x81", nil], - ["ISO-2022-JP", "\x01", "ASCII-8BIT", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x01", "ASCII-8BIT", "\x01", nil], - ["ISO-2022-JP", "\x01", "ASCII-8BIT", "\x81", nil], - ["ISO-2022-JP", "\x01", "ISO-8859-1", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x01", "ISO-8859-1", "\x01", nil], - ["ISO-2022-JP", "\x01", "ISO-8859-1", "\x81", nil], - ["ISO-2022-JP", "\x01", "UTF-16BE", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x01", "UTF-16BE", "\x01", nil], - ["ISO-2022-JP", "\x01", "UTF-16BE", "\x81", nil], - ["ISO-2022-JP", "\x01", "ISO-2022-JP", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x01", "ISO-2022-JP", "\x01", "ISO-2022-JP"], - ["ISO-2022-JP", "\x01", "ISO-2022-JP", "\x81", "ISO-2022-JP"], - ["ISO-2022-JP", "\x81", "US-ASCII", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x81", "US-ASCII", "\x01", nil], - ["ISO-2022-JP", "\x81", "US-ASCII", "\x81", nil], - ["ISO-2022-JP", "\x81", "UTF-8", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x81", "UTF-8", "\u0001", nil], - ["ISO-2022-JP", "\x81", "UTF-8", "\x81", nil], - ["ISO-2022-JP", "\x81", "ASCII-8BIT", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x81", "ASCII-8BIT", "\x01", nil], - ["ISO-2022-JP", "\x81", "ASCII-8BIT", "\x81", nil], - ["ISO-2022-JP", "\x81", "ISO-8859-1", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x81", "ISO-8859-1", "\x01", nil], - ["ISO-2022-JP", "\x81", "ISO-8859-1", "\x81", nil], - ["ISO-2022-JP", "\x81", "UTF-16BE", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x81", "UTF-16BE", "\x01", nil], - ["ISO-2022-JP", "\x81", "UTF-16BE", "\x81", nil], - ["ISO-2022-JP", "\x81", "ISO-2022-JP", "", "ISO-2022-JP"], - ["ISO-2022-JP", "\x81", "ISO-2022-JP", "\x01", "ISO-2022-JP"], - ["ISO-2022-JP", "\x81", "ISO-2022-JP", "\x81", "ISO-2022-JP"], + ["ISO-2022-JP", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"], + ["ISO-2022-JP", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x01", "US-ASCII", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x01", "US-ASCII", "\x01\x01", nil], + ["ISO-2022-JP", "\x01\x01", "US-ASCII", "\x01\x81", nil], + ["ISO-2022-JP", "\x01\x01", "UTF-8", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x01", "UTF-8", "\u0001\u0001", nil], + ["ISO-2022-JP", "\x01\x01", "UTF-8", "\u0001\x81", nil], + ["ISO-2022-JP", "\x01\x01", "ASCII-8BIT", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x01", "ASCII-8BIT", "\x01\x01", nil], + ["ISO-2022-JP", "\x01\x01", "ASCII-8BIT", "\x01\x81", nil], + ["ISO-2022-JP", "\x01\x01", "ISO-8859-1", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x01", "ISO-8859-1", "\x01\x01", nil], + ["ISO-2022-JP", "\x01\x01", "ISO-8859-1", "\x01\x81", nil], + ["ISO-2022-JP", "\x01\x01", "UTF-16BE", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x01", "UTF-16BE", "\u0101", nil], + ["ISO-2022-JP", "\x01\x01", "UTF-16BE", "\u0181", nil], + ["ISO-2022-JP", "\x01\x01", "ISO-2022-JP", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x01", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x01", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x81", "US-ASCII", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x81", "US-ASCII", "\x01\x01", nil], + ["ISO-2022-JP", "\x01\x81", "US-ASCII", "\x01\x81", nil], + ["ISO-2022-JP", "\x01\x81", "UTF-8", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x81", "UTF-8", "\u0001\u0001", nil], + ["ISO-2022-JP", "\x01\x81", "UTF-8", "\u0001\x81", nil], + ["ISO-2022-JP", "\x01\x81", "ASCII-8BIT", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x81", "ASCII-8BIT", "\x01\x01", nil], + ["ISO-2022-JP", "\x01\x81", "ASCII-8BIT", "\x01\x81", nil], + ["ISO-2022-JP", "\x01\x81", "ISO-8859-1", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x81", "ISO-8859-1", "\x01\x01", nil], + ["ISO-2022-JP", "\x01\x81", "ISO-8859-1", "\x01\x81", nil], + ["ISO-2022-JP", "\x01\x81", "UTF-16BE", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x81", "UTF-16BE", "\u0101", nil], + ["ISO-2022-JP", "\x01\x81", "UTF-16BE", "\u0181", nil], + ["ISO-2022-JP", "\x01\x81", "ISO-2022-JP", "", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x81", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"], + ["ISO-2022-JP", "\x01\x81", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"], ] matrix.each do |encoding1, value1, encoding2, value2, compatible_encoding| diff --git a/spec/ruby/core/exception/system_call_error_spec.rb b/spec/ruby/core/exception/system_call_error_spec.rb index 73167bc288..f6995d3c5e 100644 --- a/spec/ruby/core/exception/system_call_error_spec.rb +++ b/spec/ruby/core/exception/system_call_error_spec.rb @@ -53,6 +53,11 @@ describe "SystemCallError.new" do e.should be_an_instance_of(@example_errno_class) end + it "sets an error message corresponding to an appropriate Errno class" do + e = SystemCallError.new(@example_errno) + e.message.should == 'Invalid argument' + end + it "accepts an optional custom message preceding the errno" do exc = SystemCallError.new("custom message", @example_errno) exc.should be_an_instance_of(@example_errno_class) @@ -81,6 +86,35 @@ describe "SystemCallError.new" do SystemCallError.new('foo', 2.9).should == SystemCallError.new('foo', 2) end + it "treats nil errno as unknown error value" do + SystemCallError.new(nil).should be_an_instance_of(SystemCallError) + end + + it "treats nil custom message as if it is not passed at all" do + exc = SystemCallError.new(nil, @example_errno) + exc.message.should == 'Invalid argument' + end + + it "sets an 'unknown error' message when an unknown error number" do + platform_is_not :windows do + SystemCallError.new(-1).message.should =~ /Unknown error(:)? -1/ + end + + platform_is :windows do + SystemCallError.new(-1).message.should == "The operation completed successfully." + end + end + + it "adds a custom error message to an 'unknown error' message when an unknown error number and a custom message specified" do + platform_is_not :windows do + SystemCallError.new("custom message", -1).message.should =~ /Unknown error(:)? -1 - custom message/ + end + + platform_is :windows do + SystemCallError.new("custom message", -1).message.should == "The operation completed successfully. - custom message" + end + end + it "converts to Integer if errno is a Complex convertible to Integer" do SystemCallError.new('foo', Complex(2.9, 0)).should == SystemCallError.new('foo', 2) end diff --git a/spec/ruby/core/io/pread_spec.rb b/spec/ruby/core/io/pread_spec.rb index 6d93b432c2..dc7bcedf3e 100644 --- a/spec/ruby/core/io/pread_spec.rb +++ b/spec/ruby/core/io/pread_spec.rb @@ -59,6 +59,12 @@ guard -> { platform_is_not :windows or ruby_version_is "3.3" } do @file.pread(0, 4).should == "" end + it "returns a buffer for maxlen = 0 when buffer specified" do + buffer = +"foo" + @file.pread(0, 4, buffer).should.equal?(buffer) + buffer.should == "foo" + end + it "ignores the offset for maxlen = 0, even if it is out of file bounds" do @file.pread(0, 400).should == "" end diff --git a/spec/ruby/core/io/set_encoding_by_bom_spec.rb b/spec/ruby/core/io/set_encoding_by_bom_spec.rb index 92433d6640..30d5ce5a5a 100644 --- a/spec/ruby/core/io/set_encoding_by_bom_spec.rb +++ b/spec/ruby/core/io/set_encoding_by_bom_spec.rb @@ -62,11 +62,11 @@ describe "IO#set_encoding_by_bom" do @io.rewind @io.set_encoding(Encoding::ASCII_8BIT) - File.binwrite(@name, "\xFE\xFFabc") + File.binwrite(@name, "\xFE\xFFabcd") @io.set_encoding_by_bom.should == Encoding::UTF_16BE @io.external_encoding.should == Encoding::UTF_16BE - @io.read.b.should == "abc".b + @io.read.b.should == "abcd".b end it "returns the result encoding if found BOM UTF_32LE sequence" do @@ -94,11 +94,11 @@ describe "IO#set_encoding_by_bom" do @io.rewind @io.set_encoding(Encoding::ASCII_8BIT) - File.binwrite(@name, "\x00\x00\xFE\xFFabc") + File.binwrite(@name, "\x00\x00\xFE\xFFabcd") @io.set_encoding_by_bom.should == Encoding::UTF_32BE @io.external_encoding.should == Encoding::UTF_32BE - @io.read.b.should == "abc".b + @io.read.b.should == "abcd".b end it "returns nil if io is empty" do diff --git a/spec/ruby/core/kernel/sleep_spec.rb b/spec/ruby/core/kernel/sleep_spec.rb index 607764464f..4401e54256 100644 --- a/spec/ruby/core/kernel/sleep_spec.rb +++ b/spec/ruby/core/kernel/sleep_spec.rb @@ -51,18 +51,15 @@ describe "Kernel#sleep" do t.value.should == 5 end - quarantine! do # fails transiently on at least linux & darwin - it "sleeps with nanosecond precision" do - start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - 100.times do - sleep(0.0001) - end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - - actual_duration = end_time - start_time - (actual_duration > 0.01).should == true # 100 * 0.0001 => 0.01 - (actual_duration < 0.03).should == true + it "sleeps with nanosecond precision" do + start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + 100.times do + sleep(0.0001) end + end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + + actual_duration = end_time - start_time + actual_duration.should > 0.01 # 100 * 0.0001 => 0.01 end ruby_version_is ""..."3.3" do diff --git a/spec/ruby/core/marshal/dump_spec.rb b/spec/ruby/core/marshal/dump_spec.rb index adabfdf025..05e473c64e 100644 --- a/spec/ruby/core/marshal/dump_spec.rb +++ b/spec/ruby/core/marshal/dump_spec.rb @@ -283,6 +283,28 @@ describe "Marshal.dump" do end end + ruby_version_is "3.2" do + describe "with a Data" do + it "dumps a Data" do + Marshal.dump(MarshalSpec::DataSpec::Measure.new(100, 'km')).should == "\x04\bS:#MarshalSpec::DataSpec::Measure\a:\vamountii:\tunit\"\akm" + end + + it "dumps an extended Data" do + obj = MarshalSpec::DataSpec::MeasureExtended.new(100, "km") + Marshal.dump(obj).should == "\x04\bS:+MarshalSpec::DataSpec::MeasureExtended\a:\vamountii:\tunit\"\akm" + end + + it "ignores overridden name method" do + obj = MarshalSpec::DataSpec::MeasureWithOverriddenName.new(100, "km") + Marshal.dump(obj).should == "\x04\bS:5MarshalSpec::DataSpec::MeasureWithOverriddenName\a:\vamountii:\tunit\"\akm" + end + + it "raises TypeError with an anonymous Struct" do + -> { Marshal.dump(Data.define(:a).new(1)) }.should raise_error(TypeError, /can't dump anonymous class/) + end + end + end + describe "with a String" do it "dumps a blank String" do Marshal.dump("".dup.force_encoding("binary")).should == "\004\b\"\000" diff --git a/spec/ruby/core/marshal/fixtures/marshal_data.rb b/spec/ruby/core/marshal/fixtures/marshal_data.rb index aae3fce0aa..97fd78b2d7 100644 --- a/spec/ruby/core/marshal/fixtures/marshal_data.rb +++ b/spec/ruby/core/marshal/fixtures/marshal_data.rb @@ -486,6 +486,22 @@ module MarshalSpec "\004\bS:\024Struct::Pyramid\000"], "Random" => random_data, } + + if defined? Data # TODO: remove the condition when minimal supported version is 3.2 + module DataSpec + Measure = Data.define(:amount, :unit) + Empty = Data.define + + MeasureExtended = Class.new(Measure) + MeasureExtended.extend(Enumerable) + + class MeasureWithOverriddenName < Measure + def self.name + "Foo" + end + end + end + end end class ArraySub < Array diff --git a/spec/ruby/core/marshal/shared/load.rb b/spec/ruby/core/marshal/shared/load.rb index 4eac21a952..fd6490153c 100644 --- a/spec/ruby/core/marshal/shared/load.rb +++ b/spec/ruby/core/marshal/shared/load.rb @@ -749,6 +749,34 @@ describe :marshal_load, shared: true do end end + ruby_version_is "3.2" do + describe "for a Data" do + it "loads a Data" do + obj = MarshalSpec::DataSpec::Measure.new(100, 'km') + dumped = "\x04\bS:#MarshalSpec::DataSpec::Measure\a:\vamountii:\tunit\"\akm" + Marshal.dump(obj).should == dumped + + Marshal.send(@method, dumped).should == obj + end + + it "loads an extended Data" do + obj = MarshalSpec::DataSpec::MeasureExtended.new(100, "km") + dumped = "\x04\bS:+MarshalSpec::DataSpec::MeasureExtended\a:\vamountii:\tunit\"\akm" + Marshal.dump(obj).should == dumped + + Marshal.send(@method, dumped).should == obj + end + + it "returns a frozen object" do + obj = MarshalSpec::DataSpec::Measure.new(100, 'km') + dumped = "\x04\bS:#MarshalSpec::DataSpec::Measure\a:\vamountii:\tunit\"\akm" + Marshal.dump(obj).should == dumped + + Marshal.send(@method, dumped).should.frozen? + end + end + end + describe "for an Exception" do it "loads a marshalled exception with no message" do obj = Exception.new diff --git a/spec/ruby/core/process/status/bit_and_spec.rb b/spec/ruby/core/process/status/bit_and_spec.rb index 97f768fdc1..f4a4328907 100644 --- a/spec/ruby/core/process/status/bit_and_spec.rb +++ b/spec/ruby/core/process/status/bit_and_spec.rb @@ -1,5 +1,35 @@ require_relative '../../../spec_helper' describe "Process::Status#&" do - it "needs to be reviewed for spec completeness" + it "returns a bitwise and of the integer status of an exited child" do + suppress_warning do + ruby_exe("exit(29)", exit_status: 29) + ($? & 0).should == 0 + ($? & $?.to_i).should == $?.to_i + + # Actual value is implementation specific + platform_is :linux do + # 29 == 0b11101 + ($? & 0b1011100000000).should == 0b1010100000000 + end + end + end + + ruby_version_is "3.3" do + it "raises an ArgumentError if mask is negative" do + suppress_warning do + ruby_exe("exit(0)") + -> { + $? & -1 + }.should raise_error(ArgumentError, 'negative mask value: -1') + end + end + + it "shows a deprecation warning" do + ruby_exe("exit(0)") + -> { + $? & 0 + }.should complain(/warning: Process::Status#& is deprecated and will be removed .*use other Process::Status predicates instead/) + end + end end diff --git a/spec/ruby/core/process/status/right_shift_spec.rb b/spec/ruby/core/process/status/right_shift_spec.rb index e9dda437e8..034ce348cb 100644 --- a/spec/ruby/core/process/status/right_shift_spec.rb +++ b/spec/ruby/core/process/status/right_shift_spec.rb @@ -1,5 +1,34 @@ require_relative '../../../spec_helper' describe "Process::Status#>>" do - it "needs to be reviewed for spec completeness" + it "returns a right shift of the integer status of an exited child" do + suppress_warning do + ruby_exe("exit(29)", exit_status: 29) + ($? >> 0).should == $?.to_i + ($? >> 1).should == $?.to_i >> 1 + + # Actual value is implementation specific + platform_is :linux do + ($? >> 8).should == 29 + end + end + end + + ruby_version_is "3.3" do + it "raises an ArgumentError if shift value is negative" do + suppress_warning do + ruby_exe("exit(0)") + -> { + $? >> -1 + }.should raise_error(ArgumentError, 'negative shift value: -1') + end + end + + it "shows a deprecation warning" do + ruby_exe("exit(0)") + -> { + $? >> 0 + }.should complain(/warning: Process::Status#>> is deprecated and will be removed .*use other Process::Status attributes instead/) + end + end end diff --git a/spec/ruby/core/range/reverse_each_spec.rb b/spec/ruby/core/range/reverse_each_spec.rb new file mode 100644 index 0000000000..b51e04c3ff --- /dev/null +++ b/spec/ruby/core/range/reverse_each_spec.rb @@ -0,0 +1,103 @@ +require_relative '../../spec_helper' + +ruby_version_is "3.3" do + describe "Range#reverse_each" do + it "traverses the Range in reverse order and passes each element to block" do + a = [] + (1..3).reverse_each { |i| a << i } + a.should == [3, 2, 1] + + a = [] + (1...3).reverse_each { |i| a << i } + a.should == [2, 1] + end + + it "returns self" do + r = (1..3) + r.reverse_each { |x| }.should equal(r) + end + + it "returns an Enumerator if no block given" do + enum = (1..3).reverse_each + enum.should be_an_instance_of(Enumerator) + enum.to_a.should == [3, 2, 1] + end + + it "raises a TypeError for endless Ranges of Integers" do + -> { + (1..).reverse_each.take(3) + }.should raise_error(TypeError, "can't iterate from NilClass") + end + + it "raises a TypeError for endless Ranges of non-Integers" do + -> { + ("a"..).reverse_each.take(3) + }.should raise_error(TypeError, "can't iterate from NilClass") + end + + context "Integer boundaries" do + it "supports beginningless Ranges" do + (..5).reverse_each.take(3).should == [5, 4, 3] + end + end + + context "non-Integer boundaries" do + it "uses #succ to iterate a Range of non-Integer elements" do + y = mock('y') + x = mock('x') + + x.should_receive(:succ).any_number_of_times.and_return(y) + x.should_receive(:<=>).with(y).any_number_of_times.and_return(-1) + x.should_receive(:<=>).with(x).any_number_of_times.and_return(0) + y.should_receive(:<=>).with(x).any_number_of_times.and_return(1) + y.should_receive(:<=>).with(y).any_number_of_times.and_return(0) + + a = [] + (x..y).each { |i| a << i } + a.should == [x, y] + end + + it "uses #succ to iterate a Range of Strings" do + a = [] + ('A'..'D').reverse_each { |i| a << i } + a.should == ['D','C','B','A'] + end + + it "uses #succ to iterate a Range of Symbols" do + a = [] + (:A..:D).reverse_each { |i| a << i } + a.should == [:D, :C, :B, :A] + end + + it "raises a TypeError when `begin` value does not respond to #succ" do + -> { (Time.now..Time.now).reverse_each { |x| x } }.should raise_error(TypeError, /can't iterate from Time/) + -> { (//..//).reverse_each { |x| x } }.should raise_error(TypeError, /can't iterate from Regexp/) + -> { ([]..[]).reverse_each { |x| x } }.should raise_error(TypeError, /can't iterate from Array/) + end + + it "does not support beginningless Ranges" do + -> { + (..'a').reverse_each { |x| x } + }.should raise_error(TypeError, /can't iterate from NilClass/) + end + end + + context "when no block is given" do + describe "returned Enumerator size" do + it "returns the Range size when Range size is finite" do + (1..3).reverse_each.size.should == 3 + end + + ruby_bug "#20936", "3.4"..."3.5" do + it "returns Infinity when Range size is infinite" do + (..3).reverse_each.size.should == Float::INFINITY + end + end + + it "returns nil when Range size is unknown" do + ('a'..'z').reverse_each.size.should == nil + end + end + end + end +end diff --git a/spec/ruby/core/refinement/refined_class_spec.rb b/spec/ruby/core/refinement/refined_class_spec.rb index 00b65d0895..acc6e2cb2b 100644 --- a/spec/ruby/core/refinement/refined_class_spec.rb +++ b/spec/ruby/core/refinement/refined_class_spec.rb @@ -1,8 +1,29 @@ -require_relative '../../spec_helper' +require_relative "../../spec_helper" +require_relative 'shared/target' describe "Refinement#refined_class" do ruby_version_is "3.2"..."3.3" do - it "returns the class refined by the receiver" do + it_behaves_like :refinement_target, :refined_class + end + + ruby_version_is "3.3"..."3.4" do + it "has been deprecated in favour of Refinement#target" do + refinement_int = nil + + Module.new do + refine Integer do + refinement_int = self + end + end + + -> { + refinement_int.refined_class + }.should complain(/warning: Refinement#refined_class is deprecated and will be removed in Ruby 3.4; use Refinement#target instead/) + end + end + + ruby_version_is "3.4" do + it "has been removed" do refinement_int = nil Module.new do @@ -11,7 +32,7 @@ describe "Refinement#refined_class" do end end - refinement_int.refined_class.should == Integer + refinement_int.should_not.respond_to?(:refined_class) end end end diff --git a/spec/ruby/core/refinement/shared/target.rb b/spec/ruby/core/refinement/shared/target.rb new file mode 100644 index 0000000000..79557bea0b --- /dev/null +++ b/spec/ruby/core/refinement/shared/target.rb @@ -0,0 +1,13 @@ +describe :refinement_target, shared: true do + it "returns the class refined by the receiver" do + refinement_int = nil + + Module.new do + refine Integer do + refinement_int = self + end + end + + refinement_int.send(@method).should == Integer + end +end diff --git a/spec/ruby/core/refinement/target_spec.rb b/spec/ruby/core/refinement/target_spec.rb new file mode 100644 index 0000000000..fee9588a96 --- /dev/null +++ b/spec/ruby/core/refinement/target_spec.rb @@ -0,0 +1,8 @@ +require_relative "../../spec_helper" +require_relative 'shared/target' + +describe "Refinement#target" do + ruby_version_is "3.3" do + it_behaves_like :refinement_target, :target + end +end diff --git a/spec/ruby/core/string/unpack/shared/basic.rb b/spec/ruby/core/string/unpack/shared/basic.rb index bb5302edc5..b37a447683 100644 --- a/spec/ruby/core/string/unpack/shared/basic.rb +++ b/spec/ruby/core/string/unpack/shared/basic.rb @@ -8,6 +8,15 @@ describe :string_unpack_basic, shared: true do d.should_receive(:to_str).and_return("a"+unpack_format) "abc".unpack(d).should be_an_instance_of(Array) end + + ruby_version_is "3.3" do + # https://bugs.ruby-lang.org/issues/19150 + it 'raise ArgumentError when a directive is unknown' do + -> { "abcdefgh".unpack("a R" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive 'R'/) + -> { "abcdefgh".unpack("a 0" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive '0'/) + -> { "abcdefgh".unpack("a :" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive ':'/) + end + end end describe :string_unpack_no_platform, shared: true do diff --git a/spec/ruby/core/time/comparison_spec.rb b/spec/ruby/core/time/comparison_spec.rb index 5b53c9fb50..866fbea72e 100644 --- a/spec/ruby/core/time/comparison_spec.rb +++ b/spec/ruby/core/time/comparison_spec.rb @@ -55,6 +55,32 @@ describe "Time#<=>" do }.should_not complain end + context "given different timezones" do + it "returns 0 if time is the same as other" do + # three timezones, all at the same timestamp + time_utc = Time.new(2000, 1, 1, 0, 0, 0, 0) + time_cet = Time.new(2000, 1, 1, 1, 0, 0, '+01:00') + time_brt = Time.new(1999, 12, 31, 21, 0, 0, '-03:00') + (time_utc <=> time_cet).should == 0 + (time_utc <=> time_brt).should == 0 + (time_cet <=> time_brt).should == 0 + end + + it "returns -1 if the first argument is before the second argument" do + # time_brt is later, even though the date is earlier + time_utc = Time.new(2000, 1, 1, 0, 0, 0, 0) + time_brt = Time.new(1999, 12, 31, 23, 0, 0, '-03:00') + (time_utc <=> time_brt).should == -1 + end + + it "returns 1 if the first argument is before the second argument" do + # time_brt is later, even though the date is earlier + time_utc = Time.new(2000, 1, 1, 0, 0, 0, 0) + time_brt = Time.new(1999, 12, 31, 23, 0, 0, '-03:00') + (time_brt <=> time_utc).should == 1 + end + end + describe "given a non-Time argument" do it "returns nil if argument <=> self returns nil" do t = Time.now diff --git a/spec/ruby/core/time/new_spec.rb b/spec/ruby/core/time/new_spec.rb index c310a8631e..24bb9fde0c 100644 --- a/spec/ruby/core/time/new_spec.rb +++ b/spec/ruby/core/time/new_spec.rb @@ -564,6 +564,12 @@ describe "Time.new with a timezone argument" do Time.new("2020-12-25") }.should raise_error(ArgumentError, /no time information|can't parse:/) end + + it "raises ArgumentError if day is missing" do + -> { + Time.new("2020-12") + }.should raise_error(ArgumentError, /no time information|can't parse:/) + end end it "raises ArgumentError if subsecond is missing after dot" do @@ -679,6 +685,26 @@ describe "Time.new with a timezone argument" do Time.new("2021-11-31 00:00:59 +09:00 abc") }.should raise_error(ArgumentError, /can't parse.+ abc/) end + + ruby_version_is "3.2.3" do + it "raises ArgumentError when there are leading space characters" do + -> { Time.new(" 2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("\t2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("\n2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("\v2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("\f2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("\r2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) + end + + it "raises ArgumentError when there are trailing whitespaces" do + -> { Time.new("2020-12-02 00:00:00 ") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00\t") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00\n") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00\v") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00\f") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00\r") }.should raise_error(ArgumentError, /can't parse/) + end + end end end end diff --git a/spec/ruby/core/time/shared/gmtime.rb b/spec/ruby/core/time/shared/gmtime.rb index bae19da462..7b4f65f0b7 100644 --- a/spec/ruby/core/time/shared/gmtime.rb +++ b/spec/ruby/core/time/shared/gmtime.rb @@ -4,7 +4,14 @@ describe :time_gmtime, shared: true do with_timezone("CST", -6) do t = Time.local(2007, 1, 9, 6, 0, 0) t.send(@method) - t.should == Time.gm(2007, 1, 9, 12, 0, 0) + # Time#== compensates for time zones, so check all parts separately + t.year.should == 2007 + t.month.should == 1 + t.mday.should == 9 + t.hour.should == 12 + t.min.should == 0 + t.sec.should == 0 + t.zone.should == "UTC" end end diff --git a/spec/ruby/core/tracepoint/raised_exception_spec.rb b/spec/ruby/core/tracepoint/raised_exception_spec.rb index ca2f50abb3..5ac8531840 100644 --- a/spec/ruby/core/tracepoint/raised_exception_spec.rb +++ b/spec/ruby/core/tracepoint/raised_exception_spec.rb @@ -17,4 +17,22 @@ describe 'TracePoint#raised_exception' do raised_exception.should equal(error_result) end end + + ruby_version_is "3.3" do + it 'returns value from exception rescued on the :rescue event' do + raised_exception, error_result = nil + trace = TracePoint.new(:rescue) { |tp| + next unless TracePointSpec.target_thread? + raised_exception = tp.raised_exception + } + trace.enable do + begin + raise StandardError + rescue => e + error_result = e + end + raised_exception.should equal(error_result) + end + end + end end |