diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-06-27 21:02:36 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-06-27 21:02:36 +0200 |
commit | d80e44deec77678fe2d72f94c17b2409b3e794d5 (patch) | |
tree | 612bf2313550e0982dda452f48492cc069e1c21a /spec/ruby/core/encoding | |
parent | c940397116c5aef76b1c0d05561c11d43ef596a7 (diff) | |
download | ruby-d80e44deec77678fe2d72f94c17b2409b3e794d5.tar.gz |
Update to ruby/spec@8d74d49
Diffstat (limited to 'spec/ruby/core/encoding')
6 files changed, 43 insertions, 43 deletions
diff --git a/spec/ruby/core/encoding/compatible_spec.rb b/spec/ruby/core/encoding/compatible_spec.rb index 8c2e4d7e09..dc47a6553a 100644 --- a/spec/ruby/core/encoding/compatible_spec.rb +++ b/spec/ruby/core/encoding/compatible_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../spec_helper' @@ -14,12 +14,12 @@ describe "Encoding.compatible? String, String" do Encoding.compatible?(@str, "def".encode("us-ascii")).should == Encoding::US_ASCII end - it "returns US-ASCII if the second String is ASCII-8BIT and ASCII only" do + it "returns US-ASCII if the second String is BINARY and ASCII only" do Encoding.compatible?(@str, "\x7f").should == Encoding::US_ASCII end - it "returns ASCII-8BIT if the second String is ASCII-8BIT but not ASCII only" do - Encoding.compatible?(@str, "\xff").should == Encoding::ASCII_8BIT + it "returns BINARY if the second String is BINARY but not ASCII only" do + Encoding.compatible?(@str, "\xff").should == Encoding::BINARY end it "returns US-ASCII if the second String is UTF-8 and ASCII only" do @@ -39,16 +39,16 @@ describe "Encoding.compatible? String, String" do end it "returns the first's Encoding if the second is ASCII compatible and ASCII only" do - [ [Encoding, "abc".force_encoding("ASCII-8BIT"), "123".force_encoding("US-ASCII"), Encoding::ASCII_8BIT], - [Encoding, "123".force_encoding("US-ASCII"), "abc".force_encoding("ASCII-8BIT"), Encoding::US_ASCII] + [ [Encoding, "abc".force_encoding("BINARY"), "123".force_encoding("US-ASCII"), Encoding::BINARY], + [Encoding, "123".force_encoding("US-ASCII"), "abc".force_encoding("BINARY"), Encoding::US_ASCII] ].should be_computed_by(:compatible?) end it "returns the second's Encoding if the second is ASCII compatible but not ASCII only" do [ [Encoding, "abc".force_encoding("UTF-8"), "\xff".force_encoding("Shift_JIS"), Encoding::Shift_JIS], [Encoding, "123".force_encoding("Shift_JIS"), "\xff".force_encoding("UTF-8"), Encoding::UTF_8], - [Encoding, "abc".force_encoding("ASCII-8BIT"), "\xff".force_encoding("US-ASCII"), Encoding::US_ASCII], - [Encoding, "123".force_encoding("US-ASCII"), "\xff".force_encoding("ASCII-8BIT"), Encoding::ASCII_8BIT], + [Encoding, "abc".force_encoding("BINARY"), "\xff".force_encoding("US-ASCII"), Encoding::US_ASCII], + [Encoding, "123".force_encoding("US-ASCII"), "\xff".force_encoding("BINARY"), Encoding::BINARY], ].should be_computed_by(:compatible?) end @@ -61,11 +61,11 @@ describe "Encoding.compatible? String, String" do describe "when the first's Encoding is ASCII compatible but not ASCII only" do it "returns the first's Encoding if the second's is valid US-ASCII" do - Encoding.compatible?("\xff", "def".encode("us-ascii")).should == Encoding::ASCII_8BIT + Encoding.compatible?("\xff", "def".encode("us-ascii")).should == Encoding::BINARY end it "returns the first's Encoding if the second's is UTF-8 and ASCII only" do - Encoding.compatible?("\xff", "\u{7f}".encode("utf-8")).should == Encoding::ASCII_8BIT + Encoding.compatible?("\xff", "\u{7f}".encode("utf-8")).should == Encoding::BINARY end it "returns nil if the second encoding is ASCII compatible but neither String's encoding is ASCII only" do @@ -82,11 +82,11 @@ describe "Encoding.compatible? String, String" do Encoding.compatible?(@str, "def".encode("us-ascii")).should be_nil end - it "returns nil when the second String is ASCII-8BIT and ASCII only" do + it "returns nil when the second String is BINARY and ASCII only" do Encoding.compatible?(@str, "\x7f").should be_nil end - it "returns nil when the second String is ASCII-8BIT but not ASCII only" do + it "returns nil when the second String is BINARY but not ASCII only" do Encoding.compatible?(@str, "\xff").should be_nil end @@ -109,7 +109,7 @@ describe "Encoding.compatible? String, String" do Encoding.compatible?(@str, "\x7f").should == Encoding::UTF_8 end - it "returns nil when the second's Encoding is ASCII-8BIT but not ASCII only" do + it "returns nil when the second's Encoding is BINARY but not ASCII only" do Encoding.compatible?(@str, "\xff").should be_nil end @@ -170,7 +170,7 @@ describe "Encoding.compatible? String, Regexp" do end it "returns the String's Encoding if it is not US-ASCII but both are ASCII only" do - [ [Encoding, "abc", Encoding::ASCII_8BIT], + [ [Encoding, "abc", Encoding::BINARY], [Encoding, "abc".encode("utf-8"), Encoding::UTF_8], [Encoding, "abc".encode("euc-jp"), Encoding::EUC_JP], [Encoding, "abc".encode("shift_jis"), Encoding::Shift_JIS], @@ -178,7 +178,7 @@ describe "Encoding.compatible? String, Regexp" do end it "returns the String's Encoding if the String is not ASCII only" do - [ [Encoding, "\xff", Encoding::ASCII_8BIT], + [ [Encoding, "\xff", Encoding::BINARY], [Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8], [Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP], [Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS], @@ -193,7 +193,7 @@ describe "Encoding.compatible? String, Symbol" do end it "returns the String's Encoding if it is not US-ASCII but both are ASCII only" do - [ [Encoding, "abc", Encoding::ASCII_8BIT], + [ [Encoding, "abc", Encoding::BINARY], [Encoding, "abc".encode("utf-8"), Encoding::UTF_8], [Encoding, "abc".encode("euc-jp"), Encoding::EUC_JP], [Encoding, "abc".encode("shift_jis"), Encoding::Shift_JIS], @@ -201,7 +201,7 @@ describe "Encoding.compatible? String, Symbol" do end it "returns the String's Encoding if the String is not ASCII only" do - [ [Encoding, "\xff", Encoding::ASCII_8BIT], + [ [Encoding, "\xff", Encoding::BINARY], [Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8], [Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP], [Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS], @@ -219,7 +219,7 @@ describe "Encoding.compatible? String, Encoding" do end it "returns the String's encoding if the Encoding is US-ASCII" do - [ [Encoding, "\xff", Encoding::ASCII_8BIT], + [ [Encoding, "\xff", Encoding::BINARY], [Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8], [Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP], [Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS], @@ -229,14 +229,14 @@ describe "Encoding.compatible? String, Encoding" do it "returns the Encoding if the String's encoding is ASCII compatible and the String is ASCII only" do str = "abc".encode("utf-8") - Encoding.compatible?(str, Encoding::ASCII_8BIT).should == Encoding::ASCII_8BIT + Encoding.compatible?(str, Encoding::BINARY).should == Encoding::BINARY Encoding.compatible?(str, Encoding::UTF_8).should == Encoding::UTF_8 Encoding.compatible?(str, Encoding::EUC_JP).should == Encoding::EUC_JP Encoding.compatible?(str, Encoding::Shift_JIS).should == Encoding::Shift_JIS end it "returns nil if the String's encoding is ASCII compatible but the string is not ASCII only" do - Encoding.compatible?("\u3042".encode("utf-8"), Encoding::ASCII_8BIT).should be_nil + Encoding.compatible?("\u3042".encode("utf-8"), Encoding::BINARY).should be_nil end end @@ -254,7 +254,7 @@ describe "Encoding.compatible? Regexp, Regexp" do end it "returns the first's Encoding if it is not US-ASCII and not ASCII only" do - [ [Encoding, Regexp.new("\xff"), Encoding::ASCII_8BIT], + [ [Encoding, Regexp.new("\xff"), Encoding::BINARY], [Encoding, Regexp.new("\u3042".encode("utf-8")), Encoding::UTF_8], [Encoding, Regexp.new("\xa4\xa2".force_encoding("euc-jp")), Encoding::EUC_JP], [Encoding, Regexp.new("\x82\xa0".force_encoding("shift_jis")), Encoding::Shift_JIS], @@ -268,7 +268,7 @@ describe "Encoding.compatible? Regexp, Symbol" do end it "returns the first's Encoding if it is not US-ASCII and not ASCII only" do - [ [Encoding, Regexp.new("\xff"), Encoding::ASCII_8BIT], + [ [Encoding, Regexp.new("\xff"), Encoding::BINARY], [Encoding, Regexp.new("\u3042".encode("utf-8")), Encoding::UTF_8], [Encoding, Regexp.new("\xa4\xa2".force_encoding("euc-jp")), Encoding::EUC_JP], [Encoding, Regexp.new("\x82\xa0".force_encoding("shift_jis")), Encoding::Shift_JIS], @@ -294,7 +294,7 @@ describe "Encoding.compatible? Symbol, Regexp" do c = Regexp.new("\xa4\xa2".force_encoding("euc-jp")) d = Regexp.new("\x82\xa0".force_encoding("shift_jis")) - [ [Encoding, :abc, a, Encoding::ASCII_8BIT], + [ [Encoding, :abc, a, Encoding::BINARY], [Encoding, :abc, b, Encoding::UTF_8], [Encoding, :abc, c, Encoding::EUC_JP], [Encoding, :abc, d, Encoding::Shift_JIS], @@ -308,7 +308,7 @@ describe "Encoding.compatible? Symbol, Symbol" do end it "returns the first's Encoding if it is not ASCII only" do - [ [Encoding, "\xff".to_sym, Encoding::ASCII_8BIT], + [ [Encoding, "\xff".to_sym, Encoding::BINARY], [Encoding, "\u3042".encode("utf-8").to_sym, Encoding::UTF_8], [Encoding, "\xa4\xa2".force_encoding("euc-jp").to_sym, Encoding::EUC_JP], [Encoding, "\x82\xa0".force_encoding("shift_jis").to_sym, Encoding::Shift_JIS], @@ -322,15 +322,15 @@ describe "Encoding.compatible? Encoding, Encoding" do [Encoding, Encoding::US_ASCII, Encoding::UTF_7, nil], [Encoding, Encoding::EUC_JP, Encoding::UTF_7, nil], [Encoding, Encoding::UTF_7, Encoding::EUC_JP, nil], - [Encoding, Encoding::UTF_7, Encoding::ASCII_8BIT, nil], - [Encoding, Encoding::ASCII_8BIT, Encoding::UTF_7, nil], + [Encoding, Encoding::UTF_7, Encoding::BINARY, nil], + [Encoding, Encoding::BINARY, Encoding::UTF_7, nil], ].should be_computed_by(:compatible?) end it "returns nil if one of the encodings is not US-ASCII" do - [ [Encoding, Encoding::UTF_8, Encoding::ASCII_8BIT, nil], - [Encoding, Encoding::ASCII_8BIT, Encoding::UTF_8, nil], - [Encoding, Encoding::ASCII_8BIT, Encoding::EUC_JP, nil], + [ [Encoding, Encoding::UTF_8, Encoding::BINARY, nil], + [Encoding, Encoding::BINARY, Encoding::UTF_8, nil], + [Encoding, Encoding::BINARY, Encoding::EUC_JP, nil], [Encoding, Encoding::Shift_JIS, Encoding::EUC_JP, nil], ].should be_computed_by(:compatible?) end @@ -339,14 +339,14 @@ describe "Encoding.compatible? Encoding, Encoding" do [ [Encoding, Encoding::UTF_8, Encoding::US_ASCII, Encoding::UTF_8], [Encoding, Encoding::EUC_JP, Encoding::US_ASCII, Encoding::EUC_JP], [Encoding, Encoding::Shift_JIS, Encoding::US_ASCII, Encoding::Shift_JIS], - [Encoding, Encoding::ASCII_8BIT, Encoding::US_ASCII, Encoding::ASCII_8BIT], + [Encoding, Encoding::BINARY, Encoding::US_ASCII, Encoding::BINARY], ].should be_computed_by(:compatible?) end it "returns the Encoding if both are the same" do [ [Encoding, Encoding::UTF_8, Encoding::UTF_8, Encoding::UTF_8], [Encoding, Encoding::US_ASCII, Encoding::US_ASCII, Encoding::US_ASCII], - [Encoding, Encoding::ASCII_8BIT, Encoding::ASCII_8BIT, Encoding::ASCII_8BIT], + [Encoding, Encoding::BINARY, Encoding::BINARY, Encoding::BINARY], [Encoding, Encoding::UTF_7, Encoding::UTF_7, Encoding::UTF_7], ].should be_computed_by(:compatible?) end diff --git a/spec/ruby/core/encoding/converter/new_spec.rb b/spec/ruby/core/encoding/converter/new_spec.rb index d62b709c52..6b9c76a093 100644 --- a/spec/ruby/core/encoding/converter/new_spec.rb +++ b/spec/ruby/core/encoding/converter/new_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' describe "Encoding::Converter.new" do @@ -96,12 +96,12 @@ describe "Encoding::Converter.new" do describe "when passed nil for the replacement object" do describe "when the destination encoding is not UTF-8" do it "sets the replacement String to '?'" do - conv = Encoding::Converter.new("us-ascii", "ascii-8bit", replace: nil) + conv = Encoding::Converter.new("us-ascii", "binary", replace: nil) conv.replacement.should == "?" end it "sets the replacement String encoding to US-ASCII" do - conv = Encoding::Converter.new("us-ascii", "ascii-8bit", replace: nil) + conv = Encoding::Converter.new("us-ascii", "binary", replace: nil) conv.replacement.encoding.should == Encoding::US_ASCII end diff --git a/spec/ruby/core/encoding/converter/search_convpath_spec.rb b/spec/ruby/core/encoding/converter/search_convpath_spec.rb index 03cb435528..bd7530405b 100644 --- a/spec/ruby/core/encoding/converter/search_convpath_spec.rb +++ b/spec/ruby/core/encoding/converter/search_convpath_spec.rb @@ -26,7 +26,7 @@ describe "Encoding::Converter.search_convpath" do it "raises an Encoding::ConverterNotFoundError if no conversion path exists" do lambda do - Encoding::Converter.search_convpath(Encoding::ASCII_8BIT, Encoding::Emacs_Mule) + Encoding::Converter.search_convpath(Encoding::BINARY, Encoding::Emacs_Mule) end.should raise_error(Encoding::ConverterNotFoundError) end end diff --git a/spec/ruby/core/encoding/default_internal_spec.rb b/spec/ruby/core/encoding/default_internal_spec.rb index d8bbb2d11d..47a6887eee 100644 --- a/spec/ruby/core/encoding/default_internal_spec.rb +++ b/spec/ruby/core/encoding/default_internal_spec.rb @@ -24,8 +24,8 @@ describe "Encoding.default_internal" do end it "returns the default internal encoding" do - Encoding.default_internal = Encoding::ASCII_8BIT - Encoding.default_internal.should == Encoding::ASCII_8BIT + Encoding.default_internal = Encoding::BINARY + Encoding.default_internal.should == Encoding::BINARY end end diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb index 4b24e1611b..a8f7354b16 100644 --- a/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb +++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb @@ -22,9 +22,9 @@ describe "Encoding::InvalidByteSequenceError#error_bytes" do @exception2.error_bytes.should == @errinfo2[-2] end - it "uses ASCII-8BIT as the encoding" do - @exception.error_bytes.encoding.should == Encoding::ASCII_8BIT + it "uses BINARY as the encoding" do + @exception.error_bytes.encoding.should == Encoding::BINARY - @exception2.error_bytes.encoding.should == Encoding::ASCII_8BIT + @exception2.error_bytes.encoding.should == Encoding::BINARY end end diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb index 6f0ff524f5..93823b5db4 100644 --- a/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb +++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb @@ -22,9 +22,9 @@ describe "Encoding::InvalidByteSequenceError#readagain_bytes" do @exception2.readagain_bytes.should == @errinfo2[-1] end - it "uses ASCII-8BIT as the encoding" do - @exception.readagain_bytes.encoding.should == Encoding::ASCII_8BIT + it "uses BINARY as the encoding" do + @exception.readagain_bytes.encoding.should == Encoding::BINARY - @exception2.readagain_bytes.encoding.should == Encoding::ASCII_8BIT + @exception2.readagain_bytes.encoding.should == Encoding::BINARY end end |