diff options
Diffstat (limited to 'spec/ruby/core/string/shared')
-rw-r--r-- | spec/ruby/core/string/shared/chars.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/string/shared/concat.rb | 12 | ||||
-rw-r--r-- | spec/ruby/core/string/shared/encode.rb | 28 | ||||
-rw-r--r-- | spec/ruby/core/string/shared/length.rb | 2 |
4 files changed, 22 insertions, 22 deletions
diff --git a/spec/ruby/core/string/shared/chars.rb b/spec/ruby/core/string/shared/chars.rb index d37bc50675..c8716521bd 100644 --- a/spec/ruby/core/string/shared/chars.rb +++ b/spec/ruby/core/string/shared/chars.rb @@ -22,7 +22,7 @@ describe :string_chars, shared: true do it "returns characters in the same encoding as self" do "&%".force_encoding('Shift_JIS').send(@method).to_a.all? {|c| c.encoding.name.should == 'Shift_JIS'} - "&%".encode('ASCII-8BIT').send(@method).to_a.all? {|c| c.encoding.name.should == 'ASCII-8BIT'} + "&%".encode('BINARY').send(@method).to_a.all? {|c| c.encoding.should == Encoding::BINARY } end it "works with multibyte characters" do diff --git a/spec/ruby/core/string/shared/concat.rb b/spec/ruby/core/string/shared/concat.rb index bc38ba9a8b..0a87410f2f 100644 --- a/spec/ruby/core/string/shared/concat.rb +++ b/spec/ruby/core/string/shared/concat.rb @@ -60,13 +60,13 @@ describe :string_concat, shared: true do end # #5855 - it "returns a ASCII-8BIT string if self is US-ASCII and the argument is between 128-255 (inclusive)" do + it "returns a BINARY string if self is US-ASCII and the argument is between 128-255 (inclusive)" do a = ("".encode(Encoding::US_ASCII).send(@method, 128)) - a.encoding.should == Encoding::ASCII_8BIT + a.encoding.should == Encoding::BINARY a.should == 128.chr a = ("".encode(Encoding::US_ASCII).send(@method, 255)) - a.encoding.should == Encoding::ASCII_8BIT + a.encoding.should == Encoding::BINARY a.should == 255.chr end @@ -152,9 +152,9 @@ describe :string_concat_encoding, shared: true do end end - describe "when self is ASCII-8BIT and argument is US-ASCII" do - it "uses ASCII-8BIT encoding" do - "abc".encode("ASCII-8BIT").send(@method, "123".encode("US-ASCII")).encoding.should == Encoding::ASCII_8BIT + describe "when self is BINARY and argument is US-ASCII" do + it "uses BINARY encoding" do + "abc".encode("BINARY").send(@method, "123".encode("US-ASCII")).encoding.should == Encoding::BINARY end end end diff --git a/spec/ruby/core/string/shared/encode.rb b/spec/ruby/core/string/shared/encode.rb index 71d46b1bd3..d13db1945e 100644 --- a/spec/ruby/core/string/shared/encode.rb +++ b/spec/ruby/core/string/shared/encode.rb @@ -9,18 +9,18 @@ describe :string_encode, shared: true do it "transcodes a 7-bit String despite no generic converting being available" do lambda do - Encoding::Converter.new Encoding::Emacs_Mule, Encoding::ASCII_8BIT + Encoding::Converter.new Encoding::Emacs_Mule, Encoding::BINARY end.should raise_error(Encoding::ConverterNotFoundError) Encoding.default_internal = Encoding::Emacs_Mule - str = "\x79".force_encoding Encoding::ASCII_8BIT + str = "\x79".force_encoding Encoding::BINARY - str.send(@method).should == "y".force_encoding(Encoding::ASCII_8BIT) + str.send(@method).should == "y".force_encoding(Encoding::BINARY) end it "raises an Encoding::ConverterNotFoundError when no conversion is possible" do Encoding.default_internal = Encoding::Emacs_Mule - str = [0x80].pack('C').force_encoding Encoding::ASCII_8BIT + str = [0x80].pack('C').force_encoding Encoding::BINARY lambda { str.send(@method) }.should raise_error(Encoding::ConverterNotFoundError) end end @@ -52,15 +52,15 @@ describe :string_encode, shared: true do it "transcodes a 7-bit String despite no generic converting being available" do lambda do - Encoding::Converter.new Encoding::Emacs_Mule, Encoding::ASCII_8BIT + Encoding::Converter.new Encoding::Emacs_Mule, Encoding::BINARY end.should raise_error(Encoding::ConverterNotFoundError) - str = "\x79".force_encoding Encoding::ASCII_8BIT - str.send(@method, Encoding::Emacs_Mule).should == "y".force_encoding(Encoding::ASCII_8BIT) + str = "\x79".force_encoding Encoding::BINARY + str.send(@method, Encoding::Emacs_Mule).should == "y".force_encoding(Encoding::BINARY) end it "raises an Encoding::ConverterNotFoundError when no conversion is possible" do - str = [0x80].pack('C').force_encoding Encoding::ASCII_8BIT + str = [0x80].pack('C').force_encoding Encoding::BINARY lambda do str.send(@method, Encoding::Emacs_Mule) end.should raise_error(Encoding::ConverterNotFoundError) @@ -95,7 +95,7 @@ describe :string_encode, shared: true do it "raises an Encoding::ConverterNotFoundError when no conversion is possible despite 'invalid: :replace, undef: :replace'" do Encoding.default_internal = Encoding::Emacs_Mule - str = [0x80].pack('C').force_encoding Encoding::ASCII_8BIT + str = [0x80].pack('C').force_encoding Encoding::BINARY lambda do str.send(@method, invalid: :replace, undef: :replace) end.should raise_error(Encoding::ConverterNotFoundError) @@ -153,7 +153,7 @@ describe :string_encode, shared: true do describe "when passed to, from, options" do it "replaces undefined characters in the destination encoding" do - str = "あ?あ".force_encoding Encoding::ASCII_8BIT + str = "あ?あ".force_encoding Encoding::BINARY result = str.send(@method, "euc-jp", "utf-8", undef: :replace) xA4xA2 = [0xA4, 0xA2].pack('CC').force_encoding('utf-8') result.should == "#{xA4xA2}?#{xA4xA2}".force_encoding("euc-jp") @@ -161,7 +161,7 @@ describe :string_encode, shared: true do it "replaces invalid characters in the destination encoding" do xFF = [0xFF].pack('C').force_encoding('utf-8') - str = "ab#{xFF}c".force_encoding Encoding::ASCII_8BIT + str = "ab#{xFF}c".force_encoding Encoding::BINARY str.send(@method, "iso-8859-1", "utf-8", invalid: :replace).should == "ab?c" end @@ -170,7 +170,7 @@ describe :string_encode, shared: true do to.should_receive(:to_str).and_return("iso-8859-1") xFF = [0xFF].pack('C').force_encoding('utf-8') - str = "ab#{xFF}c".force_encoding Encoding::ASCII_8BIT + str = "ab#{xFF}c".force_encoding Encoding::BINARY str.send(@method, to, "utf-8", invalid: :replace).should == "ab?c" end @@ -179,7 +179,7 @@ describe :string_encode, shared: true do from.should_receive(:to_str).and_return("utf-8") xFF = [0xFF].pack('C').force_encoding('utf-8') - str = "ab#{xFF}c".force_encoding Encoding::ASCII_8BIT + str = "ab#{xFF}c".force_encoding Encoding::BINARY str.send(@method, "iso-8859-1", from, invalid: :replace).should == "ab?c" end @@ -188,7 +188,7 @@ describe :string_encode, shared: true do options.should_receive(:to_hash).and_return({ invalid: :replace }) xFF = [0xFF].pack('C').force_encoding('utf-8') - str = "ab#{xFF}c".force_encoding Encoding::ASCII_8BIT + str = "ab#{xFF}c".force_encoding Encoding::BINARY str.send(@method, "iso-8859-1", "utf-8", options).should == "ab?c" end end diff --git a/spec/ruby/core/string/shared/length.rb b/spec/ruby/core/string/shared/length.rb index cea287d7a2..f387fb251c 100644 --- a/spec/ruby/core/string/shared/length.rb +++ b/spec/ruby/core/string/shared/length.rb @@ -21,6 +21,6 @@ describe :string_length, shared: true do str = 'こにちわ' str.send(@method) - str.force_encoding('ASCII-8BIT').send(@method).should == 12 + str.force_encoding('BINARY').send(@method).should == 12 end end |