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 | |
parent | c940397116c5aef76b1c0d05561c11d43ef596a7 (diff) | |
download | ruby-d80e44deec77678fe2d72f94c17b2409b3e794d5.tar.gz |
Update to ruby/spec@8d74d49
Diffstat (limited to 'spec/ruby/core')
121 files changed, 380 insertions, 446 deletions
diff --git a/spec/ruby/core/argf/binmode_spec.rb b/spec/ruby/core/argf/binmode_spec.rb index 061145a0c7..c2dd578d95 100644 --- a/spec/ruby/core/argf/binmode_spec.rb +++ b/spec/ruby/core/argf/binmode_spec.rb @@ -31,13 +31,13 @@ describe "ARGF.binmode" do end end - it "sets the file's encoding to ASCII-8BIT" do + it "sets the file's encoding to BINARY" do argf [@bin_file, @file1] do @argf.binmode @argf.binmode?.should == true - @argf.gets.encoding.should == Encoding::ASCII_8BIT + @argf.gets.encoding.should == Encoding::BINARY @argf.skip - @argf.read.encoding.should == Encoding::ASCII_8BIT + @argf.read.encoding.should == Encoding::BINARY end end end diff --git a/spec/ruby/core/array/equal_value_spec.rb b/spec/ruby/core/array/equal_value_spec.rb index 1ef8774873..a82e07b218 100644 --- a/spec/ruby/core/array/equal_value_spec.rb +++ b/spec/ruby/core/array/equal_value_spec.rb @@ -43,4 +43,9 @@ describe "Array#==" do obj.should_receive(:==).and_return(true) [obj].should == [5] end + + # See https://bugs.ruby-lang.org/issues/1720 + it "returns true for [NaN] == [NaN] because Array#== first checks with #equal? and NaN.equal?(NaN) is true" do + [Float::NAN].should == [Float::NAN] + end end diff --git a/spec/ruby/core/array/fixtures/encoded_strings.rb b/spec/ruby/core/array/fixtures/encoded_strings.rb index e31e247afe..5b85bd0e06 100644 --- a/spec/ruby/core/array/fixtures/encoded_strings.rb +++ b/spec/ruby/core/array/fixtures/encoded_strings.rb @@ -37,33 +37,33 @@ module ArraySpecs ] end - def self.array_with_utf8_and_7bit_ascii8bit_strings + def self.array_with_utf8_and_7bit_binary_strings [ 'bar', 'báz', - 'foo'.force_encoding('ASCII-8BIT') + 'foo'.force_encoding('BINARY') ] end - def self.array_with_utf8_and_ascii8bit_strings + def self.array_with_utf8_and_binary_strings [ 'bar', 'báz', - [255].pack('C').force_encoding('ASCII-8BIT') + [255].pack('C').force_encoding('BINARY') ] end - def self.array_with_usascii_and_7bit_ascii8bit_strings + def self.array_with_usascii_and_7bit_binary_strings [ 'bar'.force_encoding('US-ASCII'), - 'foo'.force_encoding('ASCII-8BIT') + 'foo'.force_encoding('BINARY') ] end - def self.array_with_usascii_and_ascii8bit_strings + def self.array_with_usascii_and_binary_strings [ 'bar'.force_encoding('US-ASCII'), - [255].pack('C').force_encoding('ASCII-8BIT') + [255].pack('C').force_encoding('BINARY') ] end end diff --git a/spec/ruby/core/array/pack/a_spec.rb b/spec/ruby/core/array/pack/a_spec.rb index 1cee3858ff..7af7a16c68 100644 --- a/spec/ruby/core/array/pack/a_spec.rb +++ b/spec/ruby/core/array/pack/a_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/array/pack/at_spec.rb b/spec/ruby/core/array/pack/at_spec.rb index 00763c70f1..3942677913 100644 --- a/spec/ruby/core/array/pack/at_spec.rb +++ b/spec/ruby/core/array/pack/at_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/array/pack/b_spec.rb b/spec/ruby/core/array/pack/b_spec.rb index 8a75825e3e..759aec13d1 100644 --- a/spec/ruby/core/array/pack/b_spec.rb +++ b/spec/ruby/core/array/pack/b_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' @@ -47,8 +47,8 @@ describe "Array#pack with format 'B'" do ].should be_computed_by(:pack, "B*") end - it "returns an ASCII-8BIT string" do - ["1"].pack("B").encoding.should == Encoding::ASCII_8BIT + it "returns an BINARY string" do + ["1"].pack("B").encoding.should == Encoding::BINARY end it "encodes the string as a sequence of bytes" do @@ -98,8 +98,8 @@ describe "Array#pack with format 'b'" do ].should be_computed_by(:pack, "b*") end - it "returns an ASCII-8BIT string" do - ["1"].pack("b").encoding.should == Encoding::ASCII_8BIT + it "returns an BINARY string" do + ["1"].pack("b").encoding.should == Encoding::BINARY end it "encodes the string as a sequence of bytes" do diff --git a/spec/ruby/core/array/pack/buffer_spec.rb b/spec/ruby/core/array/pack/buffer_spec.rb index 28b317eacb..a3a582996a 100644 --- a/spec/ruby/core/array/pack/buffer_spec.rb +++ b/spec/ruby/core/array/pack/buffer_spec.rb @@ -1,4 +1,4 @@ -# encoding: ascii-8bit +# encoding: binary require_relative '../../../spec_helper' diff --git a/spec/ruby/core/array/pack/c_spec.rb b/spec/ruby/core/array/pack/c_spec.rb index 225f0970fd..7200830331 100644 --- a/spec/ruby/core/array/pack/c_spec.rb +++ b/spec/ruby/core/array/pack/c_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' diff --git a/spec/ruby/core/array/pack/comment_spec.rb b/spec/ruby/core/array/pack/comment_spec.rb index 07daa2d6fb..254c827ccc 100644 --- a/spec/ruby/core/array/pack/comment_spec.rb +++ b/spec/ruby/core/array/pack/comment_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' diff --git a/spec/ruby/core/array/pack/h_spec.rb b/spec/ruby/core/array/pack/h_spec.rb index 51bf551ba3..81fca7d989 100644 --- a/spec/ruby/core/array/pack/h_spec.rb +++ b/spec/ruby/core/array/pack/h_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' @@ -97,8 +97,8 @@ describe "Array#pack with format 'H'" do ].should be_computed_by(:pack, "H") end - it "returns an ASCII-8BIT string" do - ["41"].pack("H").encoding.should == Encoding::ASCII_8BIT + it "returns an BINARY string" do + ["41"].pack("H").encoding.should == Encoding::BINARY end end @@ -194,7 +194,7 @@ describe "Array#pack with format 'h'" do ].should be_computed_by(:pack, "h") end - it "returns an ASCII-8BIT string" do - ["41"].pack("h").encoding.should == Encoding::ASCII_8BIT + it "returns an BINARY string" do + ["41"].pack("h").encoding.should == Encoding::BINARY end end diff --git a/spec/ruby/core/array/pack/m_spec.rb b/spec/ruby/core/array/pack/m_spec.rb index 24acf2cef2..40c2e3f1fa 100644 --- a/spec/ruby/core/array/pack/m_spec.rb +++ b/spec/ruby/core/array/pack/m_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/array/pack/shared/float.rb b/spec/ruby/core/array/pack/shared/float.rb index b9864adef5..6cd326ce9c 100644 --- a/spec/ruby/core/array/pack/shared/float.rb +++ b/spec/ruby/core/array/pack/shared/float.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- describe :array_pack_float_le, shared: true do it "encodes a positive Float" do diff --git a/spec/ruby/core/array/pack/shared/integer.rb b/spec/ruby/core/array/pack/shared/integer.rb index 0df03bbfd1..6592f85022 100644 --- a/spec/ruby/core/array/pack/shared/integer.rb +++ b/spec/ruby/core/array/pack/shared/integer.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- describe :array_pack_16bit_le, shared: true do it "encodes the least significant 16 bits of a positive number" do diff --git a/spec/ruby/core/array/pack/shared/numeric_basic.rb b/spec/ruby/core/array/pack/shared/numeric_basic.rb index 9224d6080e..632d259ab8 100644 --- a/spec/ruby/core/array/pack/shared/numeric_basic.rb +++ b/spec/ruby/core/array/pack/shared/numeric_basic.rb @@ -15,9 +15,9 @@ describe :array_pack_numeric_basic, shared: true do lambda { [false].pack(pack_format) }.should raise_error(TypeError) end - it "returns an ASCII-8BIT string" do - [0xFF].pack(pack_format).encoding.should == Encoding::ASCII_8BIT - [0xE3, 0x81, 0x82].pack(pack_format(3)).encoding.should == Encoding::ASCII_8BIT + it "returns an BINARY string" do + [0xFF].pack(pack_format).encoding.should == Encoding::BINARY + [0xE3, 0x81, 0x82].pack(pack_format(3)).encoding.should == Encoding::BINARY end end diff --git a/spec/ruby/core/array/pack/shared/string.rb b/spec/ruby/core/array/pack/shared/string.rb index 256c1c08e8..98e8c4d562 100644 --- a/spec/ruby/core/array/pack/shared/string.rb +++ b/spec/ruby/core/array/pack/shared/string.rb @@ -38,11 +38,11 @@ describe :array_pack_string, shared: true do it "returns a string in encoding of common to the concatenated results" do f = pack_format("*") - [ [["\u{3042 3044 3046 3048}", 0x2000B].pack(f+"U"), Encoding::ASCII_8BIT], - [["abcde\xd1", "\xFF\xFe\x81\x82"].pack(f+"u"), Encoding::ASCII_8BIT], - [["a".force_encoding("ascii"), "\xFF\xFe\x81\x82"].pack(f+"u"), Encoding::ASCII_8BIT], + [ [["\u{3042 3044 3046 3048}", 0x2000B].pack(f+"U"), Encoding::BINARY], + [["abcde\xd1", "\xFF\xFe\x81\x82"].pack(f+"u"), Encoding::BINARY], + [["a".force_encoding("ascii"), "\xFF\xFe\x81\x82"].pack(f+"u"), Encoding::BINARY], # under discussion [ruby-dev:37294] - [["\u{3042 3044 3046 3048}", 1].pack(f+"N"), Encoding::ASCII_8BIT] + [["\u{3042 3044 3046 3048}", 1].pack(f+"N"), Encoding::BINARY] ].should be_computed_by(:encoding) end end diff --git a/spec/ruby/core/array/pack/u_spec.rb b/spec/ruby/core/array/pack/u_spec.rb index d708518c16..8c3eb3a177 100644 --- a/spec/ruby/core/array/pack/u_spec.rb +++ b/spec/ruby/core/array/pack/u_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/array/pack/w_spec.rb b/spec/ruby/core/array/pack/w_spec.rb index 76be1f925f..ac37a0e1c0 100644 --- a/spec/ruby/core/array/pack/w_spec.rb +++ b/spec/ruby/core/array/pack/w_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' @@ -36,7 +36,7 @@ describe "Array#pack with format 'w'" do lambda { [-1].pack("w") }.should raise_error(ArgumentError) end - it "returns an ASCII-8BIT string" do - [1].pack('w').encoding.should == Encoding::ASCII_8BIT + it "returns an BINARY string" do + [1].pack('w').encoding.should == Encoding::BINARY end end diff --git a/spec/ruby/core/array/pack/x_spec.rb b/spec/ruby/core/array/pack/x_spec.rb index 45fe34d08d..2662873d03 100644 --- a/spec/ruby/core/array/pack/x_spec.rb +++ b/spec/ruby/core/array/pack/x_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/array/pack/z_spec.rb b/spec/ruby/core/array/pack/z_spec.rb index d0600f0c26..82ce7b4a1c 100644 --- a/spec/ruby/core/array/pack/z_spec.rb +++ b/spec/ruby/core/array/pack/z_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/array/shared/join.rb b/spec/ruby/core/array/shared/join.rb index 28b3d8c04c..0d07e93b2c 100644 --- a/spec/ruby/core/array/shared/join.rb +++ b/spec/ruby/core/array/shared/join.rb @@ -89,8 +89,8 @@ describe :array_join_with_default_separator, shared: true do it "uses the first encoding when other strings are compatible" do ary1 = ArraySpecs.array_with_7bit_utf8_and_usascii_strings ary2 = ArraySpecs.array_with_usascii_and_7bit_utf8_strings - ary3 = ArraySpecs.array_with_utf8_and_7bit_ascii8bit_strings - ary4 = ArraySpecs.array_with_usascii_and_7bit_ascii8bit_strings + ary3 = ArraySpecs.array_with_utf8_and_7bit_binary_strings + ary4 = ArraySpecs.array_with_usascii_and_7bit_binary_strings ary1.send(@method).encoding.should == Encoding::UTF_8 ary2.send(@method).encoding.should == Encoding::US_ASCII @@ -107,9 +107,9 @@ describe :array_join_with_default_separator, shared: true do end it "fails for arrays with incompatibly-encoded strings" do - ary_utf8_bad_ascii8bit = ArraySpecs.array_with_utf8_and_ascii8bit_strings + ary_utf8_bad_binary = ArraySpecs.array_with_utf8_and_binary_strings - lambda { ary_utf8_bad_ascii8bit.send(@method) }.should raise_error(EncodingError) + lambda { ary_utf8_bad_binary.send(@method) }.should raise_error(EncodingError) end end diff --git a/spec/ruby/core/array/to_h_spec.rb b/spec/ruby/core/array/to_h_spec.rb index 27a0b6112f..4431430216 100644 --- a/spec/ruby/core/array/to_h_spec.rb +++ b/spec/ruby/core/array/to_h_spec.rb @@ -35,6 +35,10 @@ describe "Array#to_h" do lambda { [].to_h(:a, :b) }.should raise_error(ArgumentError) end + it "produces a hash that returns nil for a missing element" do + [[:a, 1], [:b, 2]].to_h[:c].should be_nil + end + ruby_version_is "2.6" do context "with block" do it "converts [key, value] pairs returned by the block to a Hash" do diff --git a/spec/ruby/core/dir/children_spec.rb b/spec/ruby/core/dir/children_spec.rb index d28f1b1346..ef8b20b1f0 100644 --- a/spec/ruby/core/dir/children_spec.rb +++ b/spec/ruby/core/dir/children_spec.rb @@ -43,10 +43,10 @@ ruby_version_is "2.5" do it "returns children encoded with the filesystem encoding by default" do # This spec depends on the locale not being US-ASCII because if it is, the - # children that are not ascii_only? will be ASCII-8BIT encoded. + # children that are not ascii_only? will be BINARY encoded. children = Dir.children(File.join(DirSpecs.mock_dir, 'special')).sort encoding = Encoding.find("filesystem") - encoding = Encoding::ASCII_8BIT if encoding == Encoding::US_ASCII + encoding = Encoding::BINARY if encoding == Encoding::US_ASCII platform_is_not :windows do children.should include("こんにちは.txt".force_encoding(encoding)) end @@ -110,11 +110,11 @@ ruby_version_is "2.6" do it "returns children encoded with the filesystem encoding by default" do # This spec depends on the locale not being US-ASCII because if it is, the - # children that are not ascii_only? will be ASCII-8BIT encoded. + # children that are not ascii_only? will be BINARY encoded. @dir = Dir.new(File.join(DirSpecs.mock_dir, 'special')) children = @dir.children.sort encoding = Encoding.find("filesystem") - encoding = Encoding::ASCII_8BIT if encoding == Encoding::US_ASCII + encoding = Encoding::BINARY if encoding == Encoding::US_ASCII platform_is_not :windows do children.should include("こんにちは.txt".force_encoding(encoding)) end diff --git a/spec/ruby/core/dir/entries_spec.rb b/spec/ruby/core/dir/entries_spec.rb index 488acec81b..ed45287e82 100644 --- a/spec/ruby/core/dir/entries_spec.rb +++ b/spec/ruby/core/dir/entries_spec.rb @@ -42,10 +42,10 @@ describe "Dir.entries" do it "returns entries encoded with the filesystem encoding by default" do # This spec depends on the locale not being US-ASCII because if it is, the - # entries that are not ascii_only? will be ASCII-8BIT encoded. + # entries that are not ascii_only? will be BINARY encoded. entries = Dir.entries(File.join(DirSpecs.mock_dir, 'special')).sort encoding = Encoding.find("filesystem") - encoding = Encoding::ASCII_8BIT if encoding == Encoding::US_ASCII + encoding = Encoding::BINARY if encoding == Encoding::US_ASCII platform_is_not :windows do entries.should include("こんにちは.txt".force_encoding(encoding)) end diff --git a/spec/ruby/core/dir/shared/pwd.rb b/spec/ruby/core/dir/shared/pwd.rb index 94fc2fa7fb..2a8d7fe790 100644 --- a/spec/ruby/core/dir/shared/pwd.rb +++ b/spec/ruby/core/dir/shared/pwd.rb @@ -37,7 +37,7 @@ describe :dir_pwd, shared: true do it "returns a String with the filesystem encoding" do enc = Dir.send(@method).encoding if @fs_encoding == Encoding::US_ASCII - [Encoding::US_ASCII, Encoding::ASCII_8BIT].should include(enc) + [Encoding::US_ASCII, Encoding::BINARY].should include(enc) else enc.should equal(@fs_encoding) end 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 diff --git a/spec/ruby/core/enumerator/each_with_index_spec.rb b/spec/ruby/core/enumerator/each_with_index_spec.rb index 0a3c11e0b4..7332fd628b 100644 --- a/spec/ruby/core/enumerator/each_with_index_spec.rb +++ b/spec/ruby/core/enumerator/each_with_index_spec.rb @@ -10,7 +10,7 @@ describe "Enumerator#each_with_index" do enum1 = [1,2,3].select enum2 = enum1.each_with_index enum2.should be_an_instance_of(Enumerator) - enum1.should_not === enum2 + enum1.should_not == enum2 end it "raises an ArgumentError if passed extra arguments" do @@ -28,9 +28,7 @@ describe "Enumerator#each_with_index" do it "returns the iterator's return value" do [1,2,3].select.with_index { |a,b| false }.should == [] end -end -describe "Enumerator#each_with_index" do it "returns the correct value if chained with itself" do [:a].each_with_index.each_with_index.to_a.should == [[[:a,0],0]] [:a].each.with_index.with_index.to_a.should == [[[:a,0],0]] diff --git a/spec/ruby/core/env/element_reference_spec.rb b/spec/ruby/core/env/element_reference_spec.rb index 0a10cd27b8..59b53fc4b1 100644 --- a/spec/ruby/core/env/element_reference_spec.rb +++ b/spec/ruby/core/env/element_reference_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../spec_helper' describe "ENV.[]" do @@ -34,7 +34,7 @@ describe "ENV.[]" do @external = Encoding.default_external @internal = Encoding.default_internal - Encoding.default_external = Encoding::ASCII_8BIT + Encoding.default_external = Encoding::BINARY end after :each do @@ -48,7 +48,7 @@ describe "ENV.[]" do Encoding.default_internal = nil locale = Encoding.find('locale') - locale = Encoding::ASCII_8BIT if locale == Encoding::US_ASCII + locale = Encoding::BINARY if locale == Encoding::US_ASCII ENV[@variable] = "\xC3\xB8" ENV[@variable].encoding.should == locale end diff --git a/spec/ruby/core/env/shared/each.rb b/spec/ruby/core/env/shared/each.rb index 4039dd1f83..8a262e4862 100644 --- a/spec/ruby/core/env/shared/each.rb +++ b/spec/ruby/core/env/shared/each.rb @@ -30,7 +30,7 @@ describe :env_each, shared: true do @external = Encoding.default_external @internal = Encoding.default_internal - Encoding.default_external = Encoding::ASCII_8BIT + Encoding.default_external = Encoding::BINARY @locale_encoding = Encoding.find "locale" end diff --git a/spec/ruby/core/env/shared/key.rb b/spec/ruby/core/env/shared/key.rb index c40a56093e..43299beadb 100644 --- a/spec/ruby/core/env/shared/key.rb +++ b/spec/ruby/core/env/shared/key.rb @@ -1,6 +1,4 @@ describe :env_key, shared: true do - it "needs to be reviewed for completeness" - it "returns the index associated with the passed value" do ENV["foo"] = "bar" ENV.send(@method, "bar").should == "foo" diff --git a/spec/ruby/core/env/shift_spec.rb b/spec/ruby/core/env/shift_spec.rb index 8a74f4ecac..c03b5d50c5 100644 --- a/spec/ruby/core/env/shift_spec.rb +++ b/spec/ruby/core/env/shift_spec.rb @@ -30,7 +30,7 @@ describe "ENV.shift" do @external = Encoding.default_external @internal = Encoding.default_internal - Encoding.default_external = Encoding::ASCII_8BIT + Encoding.default_external = Encoding::BINARY end after :each do diff --git a/spec/ruby/core/file/chown_spec.rb b/spec/ruby/core/file/chown_spec.rb index 8660534825..512d5b4738 100644 --- a/spec/ruby/core/file/chown_spec.rb +++ b/spec/ruby/core/file/chown_spec.rb @@ -142,11 +142,3 @@ describe "File#chown" do @file.chown(nil, nil).should == 0 end end - -describe "File.chown" do - it "needs to be reviewed for spec completeness" -end - -describe "File#chown" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/file/expand_path_spec.rb b/spec/ruby/core/file/expand_path_spec.rb index 1d972023a3..aa6a3c9c63 100644 --- a/spec/ruby/core/file/expand_path_spec.rb +++ b/spec/ruby/core/file/expand_path_spec.rb @@ -141,12 +141,12 @@ describe "File.expand_path" do File.expand_path(path).encoding.should equal(Encoding::CP1251) weird_path = [222, 173, 190, 175].pack('C*') - File.expand_path(weird_path).encoding.should equal(Encoding::ASCII_8BIT) + File.expand_path(weird_path).encoding.should equal(Encoding::BINARY) end platform_is_not :windows do - it "expands a path when the default external encoding is ASCII-8BIT" do - Encoding.default_external = Encoding::ASCII_8BIT + it "expands a path when the default external encoding is BINARY" do + Encoding.default_external = Encoding::BINARY path_8bit = [222, 173, 190, 175].pack('C*') File.expand_path( path_8bit, @rootdir).should == "#{@rootdir}" + path_8bit end diff --git a/spec/ruby/core/file/fixtures/file_types.rb b/spec/ruby/core/file/fixtures/file_types.rb index 1dd0752f73..109bcfe42e 100644 --- a/spec/ruby/core/file/fixtures/file_types.rb +++ b/spec/ruby/core/file/fixtures/file_types.rb @@ -52,15 +52,10 @@ module FileSpecs end def self.socket - require 'socket' - name = tmp("ftype_socket.socket") - rm_r name - begin - socket = UNIXServer.new name - rescue ArgumentError => error - error.message.should =~ /too long/ - return - end + require_relative '../../../library/socket/fixtures/classes.rb' + + name = SocketSpecs.socket_path + socket = UNIXServer.new name begin yield name ensure diff --git a/spec/ruby/core/file/initialize_spec.rb b/spec/ruby/core/file/initialize_spec.rb index 00e2228031..9a76a95260 100644 --- a/spec/ruby/core/file/initialize_spec.rb +++ b/spec/ruby/core/file/initialize_spec.rb @@ -1,10 +1,6 @@ require_relative '../../spec_helper' describe "File#initialize" do - it "needs to be reviewed for spec completeness" -end - -describe "File#initialize" do after :each do @io.close if @io end diff --git a/spec/ruby/core/file/lchown_spec.rb b/spec/ruby/core/file/lchown_spec.rb index 7889d68559..8d95d287ba 100644 --- a/spec/ruby/core/file/lchown_spec.rb +++ b/spec/ruby/core/file/lchown_spec.rb @@ -57,7 +57,3 @@ as_superuser do end end end - -describe "File.lchown" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb index 14be5aa32a..59c13f08ed 100644 --- a/spec/ruby/core/file/open_spec.rb +++ b/spec/ruby/core/file/open_spec.rb @@ -552,9 +552,9 @@ describe "File.open" do lambda { File.open(@file, 'fake') }.should raise_error(ArgumentError) end - it "defaults external_encoding to ASCII-8BIT for binary modes" do - File.open(@file, 'rb') {|f| f.external_encoding.should == Encoding::ASCII_8BIT} - File.open(@file, 'wb+') {|f| f.external_encoding.should == Encoding::ASCII_8BIT} + it "defaults external_encoding to BINARY for binary modes" do + File.open(@file, 'rb') {|f| f.external_encoding.should == Encoding::BINARY} + File.open(@file, 'wb+') {|f| f.external_encoding.should == Encoding::BINARY} end it "uses the second argument as an options Hash" do diff --git a/spec/ruby/core/file/stat/ftype_spec.rb b/spec/ruby/core/file/stat/ftype_spec.rb index a19e7c43d7..eb892eae5f 100644 --- a/spec/ruby/core/file/stat/ftype_spec.rb +++ b/spec/ruby/core/file/stat/ftype_spec.rb @@ -55,10 +55,6 @@ describe "File::Stat#ftype" do end end - # This will silently not execute the block if no socket - # can be found. However, if you are running X, there is - # a good chance that if nothing else, at least the X - # Server socket exists. it "returns 'socket' when the file is a socket" do FileSpecs.socket do |socket| File.lstat(socket).ftype.should == 'socket' diff --git a/spec/ruby/core/file/stat/setgid_spec.rb b/spec/ruby/core/file/stat/setgid_spec.rb index 9b972f5a6d..c0748ede57 100644 --- a/spec/ruby/core/file/stat/setgid_spec.rb +++ b/spec/ruby/core/file/stat/setgid_spec.rb @@ -5,7 +5,3 @@ require_relative 'fixtures/classes' describe "File::Stat#setgid?" do it_behaves_like :file_setgid, :setgid?, FileStat end - -describe "File::Stat#setgid?" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/file/stat/setuid_spec.rb b/spec/ruby/core/file/stat/setuid_spec.rb index 892776a0ef..6408120fc4 100644 --- a/spec/ruby/core/file/stat/setuid_spec.rb +++ b/spec/ruby/core/file/stat/setuid_spec.rb @@ -5,7 +5,3 @@ require_relative 'fixtures/classes' describe "File::Stat#setuid?" do it_behaves_like :file_setuid, :setuid?, FileStat end - -describe "File::Stat#setuid?" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/file/stat/socket_spec.rb b/spec/ruby/core/file/stat/socket_spec.rb index 8dd43ec44a..09740be110 100644 --- a/spec/ruby/core/file/stat/socket_spec.rb +++ b/spec/ruby/core/file/stat/socket_spec.rb @@ -5,7 +5,3 @@ require_relative 'fixtures/classes' describe "File::Stat#socket?" do it_behaves_like :file_socket, :socket?, FileStat end - -describe "File::Stat#socket?" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/file/stat/sticky_spec.rb b/spec/ruby/core/file/stat/sticky_spec.rb index 8634253a02..7083e644e9 100644 --- a/spec/ruby/core/file/stat/sticky_spec.rb +++ b/spec/ruby/core/file/stat/sticky_spec.rb @@ -5,7 +5,3 @@ require_relative 'fixtures/classes' describe "File::Stat#sticky?" do it_behaves_like :file_sticky, :sticky?, FileStat end - -describe "File::Stat#sticky?" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/filetest/owned_spec.rb b/spec/ruby/core/filetest/owned_spec.rb index 5ffd8ced26..b26165f98d 100644 --- a/spec/ruby/core/filetest/owned_spec.rb +++ b/spec/ruby/core/filetest/owned_spec.rb @@ -4,7 +4,3 @@ require_relative '../../shared/file/owned' describe "FileTest.owned?" do it_behaves_like :file_owned, :owned?, FileTest end - -describe "FileTest.owned?" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/filetest/pipe_spec.rb b/spec/ruby/core/filetest/pipe_spec.rb index 912635b25f..8ce67568fb 100644 --- a/spec/ruby/core/filetest/pipe_spec.rb +++ b/spec/ruby/core/filetest/pipe_spec.rb @@ -4,7 +4,3 @@ require_relative '../../shared/file/pipe' describe "FileTest.pipe?" do it_behaves_like :file_pipe, :pipe?, FileTest end - -describe "FileTest.pipe?" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/filetest/setgid_spec.rb b/spec/ruby/core/filetest/setgid_spec.rb index e0feb3c8a9..c83ffccb2a 100644 --- a/spec/ruby/core/filetest/setgid_spec.rb +++ b/spec/ruby/core/filetest/setgid_spec.rb @@ -4,7 +4,3 @@ require_relative '../../shared/file/setgid' describe "FileTest.setgid?" do it_behaves_like :file_setgid, :setgid?, FileTest end - -describe "FileTest.setgid?" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/filetest/setuid_spec.rb b/spec/ruby/core/filetest/setuid_spec.rb index 4371a215ba..1c1fd2efe4 100644 --- a/spec/ruby/core/filetest/setuid_spec.rb +++ b/spec/ruby/core/filetest/setuid_spec.rb @@ -4,7 +4,3 @@ require_relative '../../shared/file/setuid' describe "FileTest.setuid?" do it_behaves_like :file_setuid, :setuid?, FileTest end - -describe "FileTest.setuid?" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/filetest/socket_spec.rb b/spec/ruby/core/filetest/socket_spec.rb index 1373c7e370..63a6a31ecb 100644 --- a/spec/ruby/core/filetest/socket_spec.rb +++ b/spec/ruby/core/filetest/socket_spec.rb @@ -4,7 +4,3 @@ require_relative '../../shared/file/socket' describe "FileTest.socket?" do it_behaves_like :file_socket, :socket?, FileTest end - -describe "FileTest.socket?" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/core/hash/merge_spec.rb b/spec/ruby/core/hash/merge_spec.rb index 54abcb816d..77e5c42071 100644 --- a/spec/ruby/core/hash/merge_spec.rb +++ b/spec/ruby/core/hash/merge_spec.rb @@ -99,11 +99,4 @@ end describe "Hash#merge!" do it_behaves_like :hash_update, :merge! - - it "does not raise an exception if changing the value of an existing key during iteration" do - hash = {1 => 2, 3 => 4, 5 => 6} - hash2 = {1 => :foo, 3 => :bar} - hash.each { hash.merge!(hash2) } - hash.should == {1 => :foo, 3 => :bar, 5 => 6} - end end diff --git a/spec/ruby/core/hash/shared/update.rb b/spec/ruby/core/hash/shared/update.rb index 250c5ab440..e808add5c0 100644 --- a/spec/ruby/core/hash/shared/update.rb +++ b/spec/ruby/core/hash/shared/update.rb @@ -57,6 +57,13 @@ describe :hash_update, shared: true do end.should raise_error(frozen_error_class) end + it "does not raise an exception if changing the value of an existing key during iteration" do + hash = {1 => 2, 3 => 4, 5 => 6} + hash2 = {1 => :foo, 3 => :bar} + hash.each { hash.send(@method, hash2) } + hash.should == {1 => :foo, 3 => :bar, 5 => 6} + end + ruby_version_is "2.6" do it "accepts multiple hashes" do result = { a: 1 }.send(@method, { b: 2 }, { c: 3 }, { d: 4 }) diff --git a/spec/ruby/core/integer/chr_spec.rb b/spec/ruby/core/integer/chr_spec.rb index 8420d85cf6..a519961d7c 100644 --- a/spec/ruby/core/integer/chr_spec.rb +++ b/spec/ruby/core/integer/chr_spec.rb @@ -30,9 +30,9 @@ describe "Integer#chr without argument" do end describe "and self is between 128 and 255 (inclusive)" do - it "returns an ASCII-8BIT String" do + it "returns an BINARY String" do (128..255).each do |c| - c.chr.encoding.should == Encoding::ASCII_8BIT + c.chr.encoding.should == Encoding::BINARY end end @@ -81,13 +81,13 @@ describe "Integer#chr without argument" do end describe "and self is between 128 and 255 (inclusive)" do - it "returns an ASCII-8BIT String" do + it "returns an BINARY String" do (128..255).each do |c| Encoding.default_internal = Encoding::UTF_8 - c.chr.encoding.should == Encoding::ASCII_8BIT + c.chr.encoding.should == Encoding::BINARY Encoding.default_internal = Encoding::SHIFT_JIS - c.chr.encoding.should == Encoding::ASCII_8BIT + c.chr.encoding.should == Encoding::BINARY end end @@ -126,7 +126,7 @@ describe "Integer#chr without argument" do # #5864 it "raises RangeError if self is invalid as a codepoint in the default internal encoding" do [ [0x0100, "US-ASCII"], - [0x0100, "ASCII-8BIT"], + [0x0100, "BINARY"], [0x0100, "EUC-JP"], [0xA1A0, "EUC-JP"], [0x0100, "ISO-8859-9"], @@ -173,10 +173,10 @@ describe "Integer#chr with an encoding argument" do 0x0000.chr(Encoding::US_ASCII).encoding.should == Encoding::US_ASCII 0x007F.chr(Encoding::US_ASCII).encoding.should == Encoding::US_ASCII - 0x0000.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT - 0x007F.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT - 0x0080.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT - 0x00FF.chr(Encoding::ASCII_8BIT).encoding.should == Encoding::ASCII_8BIT + 0x0000.chr(Encoding::BINARY).encoding.should == Encoding::BINARY + 0x007F.chr(Encoding::BINARY).encoding.should == Encoding::BINARY + 0x0080.chr(Encoding::BINARY).encoding.should == Encoding::BINARY + 0x00FF.chr(Encoding::BINARY).encoding.should == Encoding::BINARY 0x0000.chr(Encoding::UTF_8).encoding.should == Encoding::UTF_8 0x007F.chr(Encoding::UTF_8).encoding.should == Encoding::UTF_8 @@ -197,10 +197,10 @@ describe "Integer#chr with an encoding argument" do 0x0000.chr(Encoding::US_ASCII).bytes.to_a.should == [0x00] 0x007F.chr(Encoding::US_ASCII).bytes.to_a.should == [0x7F] - 0x0000.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0x00] - 0x007F.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0x7F] - 0x0080.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0x80] - 0x00FF.chr(Encoding::ASCII_8BIT).bytes.to_a.should == [0xFF] + 0x0000.chr(Encoding::BINARY).bytes.to_a.should == [0x00] + 0x007F.chr(Encoding::BINARY).bytes.to_a.should == [0x7F] + 0x0080.chr(Encoding::BINARY).bytes.to_a.should == [0x80] + 0x00FF.chr(Encoding::BINARY).bytes.to_a.should == [0xFF] 0x0000.chr(Encoding::UTF_8).bytes.to_a.should == [0x00] 0x007F.chr(Encoding::UTF_8).bytes.to_a.should == [0x7F] @@ -220,7 +220,7 @@ describe "Integer#chr with an encoding argument" do # #5864 it "raises RangeError if self is invalid as a codepoint in the specified encoding" do [ [0x80, "US-ASCII"], - [0x0100, "ASCII-8BIT"], + [0x0100, "BINARY"], [0x0100, "EUC-JP"], [0xA1A0, "EUC-JP"], [0xA1, "EUC-JP"], diff --git a/spec/ruby/core/integer/round_spec.rb b/spec/ruby/core/integer/round_spec.rb index 622a55280e..a45a7b5fb3 100644 --- a/spec/ruby/core/integer/round_spec.rb +++ b/spec/ruby/core/integer/round_spec.rb @@ -67,12 +67,15 @@ describe "Integer#round" do 25.round(-1, half: :up).should eql(30) 25.round(-1, half: :down).should eql(20) 25.round(-1, half: :even).should eql(20) + 25.round(-1, half: nil).should eql(30) 35.round(-1, half: :up).should eql(40) 35.round(-1, half: :down).should eql(30) 35.round(-1, half: :even).should eql(40) + 35.round(-1, half: nil).should eql(40) (-25).round(-1, half: :up).should eql(-30) (-25).round(-1, half: :down).should eql(-20) (-25).round(-1, half: :even).should eql(-20) + (-25).round(-1, half: nil).should eql(-30) end ruby_version_is "2.4"..."2.5" do @@ -90,4 +93,9 @@ describe "Integer#round" do 35.round(1, half: :even).should eql(35) end end + + it "raises ArgumentError for an unknown rounding mode" do + lambda { 42.round(-1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/) + lambda { 42.round(1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/) + end end diff --git a/spec/ruby/core/io/binread_spec.rb b/spec/ruby/core/io/binread_spec.rb index 5e936ac6ba..961044da58 100644 --- a/spec/ruby/core/io/binread_spec.rb +++ b/spec/ruby/core/io/binread_spec.rb @@ -28,13 +28,13 @@ describe "IO.binread" do IO.binread(@fname, 5, 3).should == @contents.slice(3, 5) end - it "returns a String in ASCII-8BIT encoding" do - IO.binread(@fname).encoding.should == Encoding::ASCII_8BIT + it "returns a String in BINARY encoding" do + IO.binread(@fname).encoding.should == Encoding::BINARY end - it "returns a String in ASCII-8BIT encoding regardless of Encoding.default_internal" do + it "returns a String in BINARY encoding regardless of Encoding.default_internal" do Encoding.default_internal = Encoding::EUC_JP - IO.binread(@fname).encoding.should == Encoding::ASCII_8BIT + IO.binread(@fname).encoding.should == Encoding::BINARY end it "raises an ArgumentError when not passed a valid length" do diff --git a/spec/ruby/core/io/binwrite_spec.rb b/spec/ruby/core/io/binwrite_spec.rb index e28ea8ebb1..8ebc86a52e 100644 --- a/spec/ruby/core/io/binwrite_spec.rb +++ b/spec/ruby/core/io/binwrite_spec.rb @@ -3,6 +3,4 @@ require_relative 'shared/binwrite' describe "IO.binwrite" do it_behaves_like :io_binwrite, :binwrite - - it "needs to be reviewed for spec completeness" end diff --git a/spec/ruby/core/io/external_encoding_spec.rb b/spec/ruby/core/io/external_encoding_spec.rb index 3581019207..9666974647 100644 --- a/spec/ruby/core/io/external_encoding_spec.rb +++ b/spec/ruby/core/io/external_encoding_spec.rb @@ -171,9 +171,9 @@ describe "IO#external_encoding" do end describe "with 'rb' mode" do - it "returns Encoding::ASCII_8BIT" do + it "returns Encoding::BINARY" do @io = new_io @name, "rb" - @io.external_encoding.should equal(Encoding::ASCII_8BIT) + @io.external_encoding.should equal(Encoding::BINARY) end it "returns the external encoding specified by the mode argument" do @@ -191,9 +191,9 @@ describe "IO#external_encoding" do end describe "with 'wb' mode" do - it "returns Encoding::ASCII_8BIT" do + it "returns Encoding::BINARY" do @io = new_io @name, "wb" - @io.external_encoding.should equal(Encoding::ASCII_8BIT) + @io.external_encoding.should equal(Encoding::BINARY) end it "returns the external encoding specified by the mode argument" do diff --git a/spec/ruby/core/io/gets_spec.rb b/spec/ruby/core/io/gets_spec.rb index ac763f2a13..371c1c3d3b 100644 --- a/spec/ruby/core/io/gets_spec.rb +++ b/spec/ruby/core/io/gets_spec.rb @@ -295,25 +295,25 @@ describe "IO#gets" do end it "overwrites the default external encoding with the IO object's own external encoding" do - Encoding.default_external = Encoding::ASCII_8BIT + Encoding.default_external = Encoding::BINARY Encoding.default_internal = Encoding::UTF_8 @io = new_io @name, 'r' @io.set_encoding Encoding::IBM866 @io.gets.encoding.should == Encoding::UTF_8 end - it "ignores the internal encoding if the default external encoding is ASCII-8BIT" do - Encoding.default_external = Encoding::ASCII_8BIT + it "ignores the internal encoding if the default external encoding is BINARY" do + Encoding.default_external = Encoding::BINARY Encoding.default_internal = Encoding::UTF_8 @io = new_io @name, 'r' - @io.gets.encoding.should == Encoding::ASCII_8BIT + @io.gets.encoding.should == Encoding::BINARY end - it "transcodes to internal encoding if the IO object's external encoding is ASCII-8BIT" do - Encoding.default_external = Encoding::ASCII_8BIT + it "transcodes to internal encoding if the IO object's external encoding is BINARY" do + Encoding.default_external = Encoding::BINARY Encoding.default_internal = Encoding::UTF_8 @io = new_io @name, 'r' - @io.set_encoding Encoding::ASCII_8BIT, Encoding::UTF_8 + @io.set_encoding Encoding::BINARY, Encoding::UTF_8 @io.gets.encoding.should == Encoding::UTF_8 end end diff --git a/spec/ruby/core/io/internal_encoding_spec.rb b/spec/ruby/core/io/internal_encoding_spec.rb index 772cdeeaaf..10ebf28707 100644 --- a/spec/ruby/core/io/internal_encoding_spec.rb +++ b/spec/ruby/core/io/internal_encoding_spec.rb @@ -82,14 +82,14 @@ describe :io_internal_encoding, shared: true do @io.internal_encoding.should equal(Encoding::IBM437) end - it "returns nil when Encoding.default_external is ASCII-8BIT and the internal encoding is not set" do - Encoding.default_external = Encoding::ASCII_8BIT + it "returns nil when Encoding.default_external is BINARY and the internal encoding is not set" do + Encoding.default_external = Encoding::BINARY @io = new_io @name, @object @io.internal_encoding.should be_nil end - it "returns nil when the external encoding is ASCII-8BIT and the internal encoding is not set" do - @io = new_io @name, "#{@object}:ascii-8bit" + it "returns nil when the external encoding is BINARY and the internal encoding is not set" do + @io = new_io @name, "#{@object}:binary" @io.internal_encoding.should be_nil end end diff --git a/spec/ruby/core/io/read_spec.rb b/spec/ruby/core/io/read_spec.rb index ccb341a1f9..e005e14fdf 100644 --- a/spec/ruby/core/io/read_spec.rb +++ b/spec/ruby/core/io/read_spec.rb @@ -380,16 +380,16 @@ describe "IO#read in binary mode" do result = File.open(@name, "rb") { |f| f.read }.chomp - result.encoding.should == Encoding::ASCII_8BIT + result.encoding.should == Encoding::BINARY xE2 = [226].pack('C*') - result.should == ("abc" + xE2 + "def").force_encoding(Encoding::ASCII_8BIT) + result.should == ("abc" + xE2 + "def").force_encoding(Encoding::BINARY) end it "does not transcode file contents when an internal encoding is specified" do result = File.open(@name, "r:binary:utf-8") { |f| f.read }.chomp - result.encoding.should == Encoding::ASCII_8BIT + result.encoding.should == Encoding::BINARY xE2 = [226].pack('C*') - result.should == ("abc" + xE2 + "def").force_encoding(Encoding::ASCII_8BIT) + result.should == ("abc" + xE2 + "def").force_encoding(Encoding::BINARY) end end @@ -420,37 +420,37 @@ describe "IO.read with BOM" do it "reads a file without a bom" do name = fixture __FILE__, "no_bom_UTF-8.txt" result = File.read(name, mode: "rb:BOM|utf-8") - result.force_encoding("ascii-8bit").should == "UTF-8\n" + result.force_encoding("binary").should == "UTF-8\n" end it "reads a file with a utf-8 bom" do name = fixture __FILE__, "bom_UTF-8.txt" result = File.read(name, mode: "rb:BOM|utf-16le") - result.force_encoding("ascii-8bit").should == "UTF-8\n" + result.force_encoding("binary").should == "UTF-8\n" end it "reads a file with a utf-16le bom" do name = fixture __FILE__, "bom_UTF-16LE.txt" result = File.read(name, mode: "rb:BOM|utf-8") - result.force_encoding("ascii-8bit").should == "U\x00T\x00F\x00-\x001\x006\x00L\x00E\x00\n\x00" + result.force_encoding("binary").should == "U\x00T\x00F\x00-\x001\x006\x00L\x00E\x00\n\x00" end it "reads a file with a utf-16be bom" do name = fixture __FILE__, "bom_UTF-16BE.txt" result = File.read(name, mode: "rb:BOM|utf-8") - result.force_encoding("ascii-8bit").should == "\x00U\x00T\x00F\x00-\x001\x006\x00B\x00E\x00\n" + result.force_encoding("binary").should == "\x00U\x00T\x00F\x00-\x001\x006\x00B\x00E\x00\n" end it "reads a file with a utf-32le bom" do name = fixture __FILE__, "bom_UTF-32LE.txt" result = File.read(name, mode: "rb:BOM|utf-8") - result.force_encoding("ascii-8bit").should == "U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00L\x00\x00\x00E\x00\x00\x00\n\x00\x00\x00" + result.force_encoding("binary").should == "U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00L\x00\x00\x00E\x00\x00\x00\n\x00\x00\x00" end it "reads a file with a utf-32be bom" do name = fixture __FILE__, "bom_UTF-32BE.txt" result = File.read(name, mode: "rb:BOM|utf-8") - result.force_encoding("ascii-8bit").should == "\x00\x00\x00U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00B\x00\x00\x00E\x00\x00\x00\n" + result.force_encoding("binary").should == "\x00\x00\x00U\x00\x00\x00T\x00\x00\x00F\x00\x00\x00-\x00\x00\x003\x00\x00\x002\x00\x00\x00B\x00\x00\x00E\x00\x00\x00\n" end end @@ -480,11 +480,11 @@ end describe :io_read_size_internal_encoding, shared: true do it "reads bytes when passed a size" do - @io.read(2).should == [164, 162].pack('C*').force_encoding(Encoding::ASCII_8BIT) + @io.read(2).should == [164, 162].pack('C*').force_encoding(Encoding::BINARY) end - it "returns a String in ASCII-8BIT when passed a size" do - @io.read(4).encoding.should equal(Encoding::ASCII_8BIT) + it "returns a String in BINARY when passed a size" do + @io.read(4).encoding.should equal(Encoding::BINARY) end it "does not change the buffer's encoding when passed a limit" do diff --git a/spec/ruby/core/io/readbyte_spec.rb b/spec/ruby/core/io/readbyte_spec.rb index f7653bf3bb..eb25975f58 100644 --- a/spec/ruby/core/io/readbyte_spec.rb +++ b/spec/ruby/core/io/readbyte_spec.rb @@ -21,6 +21,4 @@ describe "IO#readbyte" do @io.readbyte end.should raise_error EOFError end - - it "needs to be reviewed for spec completeness" end diff --git a/spec/ruby/core/io/readlines_spec.rb b/spec/ruby/core/io/readlines_spec.rb index 9e145f12f4..5a7e9b5aa8 100644 --- a/spec/ruby/core/io/readlines_spec.rb +++ b/spec/ruby/core/io/readlines_spec.rb @@ -201,10 +201,10 @@ describe "IO.readlines" do lines.all? { |s| s.encoding == Encoding::UTF_16 }.should be_true end - it "ignores the default internal encoding if the external encoding is ASCII-8BIT" do - Encoding.default_external = Encoding::ASCII_8BIT + it "ignores the default internal encoding if the external encoding is BINARY" do + Encoding.default_external = Encoding::BINARY Encoding.default_internal = Encoding::UTF_8 lines = IO.readlines(@name) - lines.all? { |s| s.encoding == Encoding::ASCII_8BIT }.should be_true + lines.all? { |s| s.encoding == Encoding::BINARY }.should be_true end end diff --git a/spec/ruby/core/io/readpartial_spec.rb b/spec/ruby/core/io/readpartial_spec.rb index 53160ca337..1ab01dcf49 100644 --- a/spec/ruby/core/io/readpartial_spec.rb +++ b/spec/ruby/core/io/readpartial_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../spec_helper' require_relative 'fixtures/classes' diff --git a/spec/ruby/core/io/set_encoding_spec.rb b/spec/ruby/core/io/set_encoding_spec.rb index a9d783325c..5aec6a96c3 100644 --- a/spec/ruby/core/io/set_encoding_spec.rb +++ b/spec/ruby/core/io/set_encoding_spec.rb @@ -87,7 +87,7 @@ describe "IO#set_encoding when passed nil, nil" do describe "with 'rb' mode" do it "returns Encoding.default_external" do @io = new_io @name, "rb" - @io.external_encoding.should equal(Encoding::ASCII_8BIT) + @io.external_encoding.should equal(Encoding::BINARY) @io.set_encoding nil, nil @io.external_encoding.should equal(Encoding.default_external) diff --git a/spec/ruby/core/io/shared/new.rb b/spec/ruby/core/io/shared/new.rb index ea22f40090..f6069a4cdc 100644 --- a/spec/ruby/core/io/shared/new.rb +++ b/spec/ruby/core/io/shared/new.rb @@ -168,13 +168,13 @@ describe :io_new, shared: true do it "sets external encoding to binary with binmode in mode string" do @io = IO.send(@method, @fd, 'wb') - @io.external_encoding.to_s.should == 'ASCII-8BIT' + @io.external_encoding.should == Encoding::BINARY end # #5917 it "sets external encoding to binary with :binmode option" do @io = IO.send(@method, @fd, 'w', {binmode: true}) - @io.external_encoding.to_s.should == 'ASCII-8BIT' + @io.external_encoding.should == Encoding::BINARY end it "does not use binary encoding when mode encoding is specified" do diff --git a/spec/ruby/core/io/write_spec.rb b/spec/ruby/core/io/write_spec.rb index 5fb3941505..5fb5cc7013 100644 --- a/spec/ruby/core/io/write_spec.rb +++ b/spec/ruby/core/io/write_spec.rb @@ -70,7 +70,7 @@ describe "IO#write on a file" do ë = ([235].pack('U')).encode('ISO-8859-1') ö = ([246].pack('U')).encode('ISO-8859-1') res = "H#{ë}ll#{ö}" - File.binread(@filename).should == res.force_encoding(Encoding::ASCII_8BIT) + File.binread(@filename).should == res.force_encoding(Encoding::BINARY) end end @@ -94,7 +94,7 @@ describe "IO.write" do IO.write(@filename, 'Hëllö'.encode('ISO-8859-1')) xEB = [235].pack('C*') xF6 = [246].pack('C*') - File.binread(@filename).should == ("H" + xEB + "ll" + xF6).force_encoding(Encoding::ASCII_8BIT) + File.binread(@filename).should == ("H" + xEB + "ll" + xF6).force_encoding(Encoding::BINARY) end platform_is_not :windows do diff --git a/spec/ruby/core/kernel/open_spec.rb b/spec/ruby/core/kernel/open_spec.rb index 5d3da871f0..3a9f5ea2d5 100644 --- a/spec/ruby/core/kernel/open_spec.rb +++ b/spec/ruby/core/kernel/open_spec.rb @@ -45,8 +45,10 @@ describe "Kernel#open" do end it "opens an io for writing" do - bytes = open("|cat", "w") { |io| io.write(".") } - bytes.should == 1 + -> do + bytes = open("|cat", "w") { |io| io.write(".") } + bytes.should == 1 + end.should output_to_fd(".") end end diff --git a/spec/ruby/core/kernel/proc_spec.rb b/spec/ruby/core/kernel/proc_spec.rb index 8c56946874..e3acfa8dfd 100644 --- a/spec/ruby/core/kernel/proc_spec.rb +++ b/spec/ruby/core/kernel/proc_spec.rb @@ -59,6 +59,4 @@ describe "Kernel#proc" do }.should complain(/Capturing the given block using Proc.new is deprecated/) end end - - it "needs to be reviewed for spec completeness" end diff --git a/spec/ruby/core/kernel/require_relative_spec.rb b/spec/ruby/core/kernel/require_relative_spec.rb index a16e7164e6..6604d30ab1 100644 --- a/spec/ruby/core/kernel/require_relative_spec.rb +++ b/spec/ruby/core/kernel/require_relative_spec.rb @@ -2,8 +2,6 @@ require_relative '../../spec_helper' require_relative '../../fixtures/code_loading' describe "Kernel#require_relative with a relative path" do - it "needs to be reviewed for spec completeness" - before :each do CodeLoadingSpecs.spec_setup @dir = "../../fixtures/code" @@ -267,8 +265,6 @@ describe "Kernel#require_relative with a relative path" do end describe "Kernel#require_relative with an absolute path" do - it "needs to be reviewed for spec completeness" - before :each do CodeLoadingSpecs.spec_setup @dir = File.expand_path "../../fixtures/code", File.dirname(__FILE__) diff --git a/spec/ruby/core/kernel/select_spec.rb b/spec/ruby/core/kernel/select_spec.rb index 2661bbfac7..e0d82f3079 100644 --- a/spec/ruby/core/kernel/select_spec.rb +++ b/spec/ruby/core/kernel/select_spec.rb @@ -8,8 +8,6 @@ describe "Kernel#select" do end describe "Kernel.select" do - it "needs to be reviewed for spec completeness" - it 'does not block when timeout is 0' do IO.pipe do |read, write| IO.select([read], [], [], 0).should == nil diff --git a/spec/ruby/core/marshal/shared/load.rb b/spec/ruby/core/marshal/shared/load.rb index a10885346e..cb041ec25c 100644 --- a/spec/ruby/core/marshal/shared/load.rb +++ b/spec/ruby/core/marshal/shared/load.rb @@ -446,11 +446,11 @@ describe :marshal_load, shared: true do result.encoding.should equal(Encoding::UTF_16LE) end - it "loads a String as ASCII-8BIT if no encoding is specified at the end" do - str = "\xC3\xB8".force_encoding("ASCII-8BIT") + it "loads a String as BINARY if no encoding is specified at the end" do + str = "\xC3\xB8".force_encoding("BINARY") data = "\x04\b\"\a\xC3\xB8".force_encoding("UTF-8") result = Marshal.send(@method, data) - result.encoding.should == Encoding::ASCII_8BIT + result.encoding.should == Encoding::BINARY result.should == str end end diff --git a/spec/ruby/core/method/hash_spec.rb b/spec/ruby/core/method/hash_spec.rb index b6807ca1e2..d6c8440acc 100644 --- a/spec/ruby/core/method/hash_spec.rb +++ b/spec/ruby/core/method/hash_spec.rb @@ -2,8 +2,6 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' describe "Method#hash" do - it "needs to be reviewed for spec completeness" - it "returns the same value for user methods that are eql?" do obj = MethodSpecs::Methods.new obj.method(:foo).hash.should == obj.method(:bar).hash diff --git a/spec/ruby/core/module/define_singleton_method_spec.rb b/spec/ruby/core/module/define_singleton_method_spec.rb index 38a4fc51b7..f2b8a5ada4 100644 --- a/spec/ruby/core/module/define_singleton_method_spec.rb +++ b/spec/ruby/core/module/define_singleton_method_spec.rb @@ -12,6 +12,4 @@ describe "Module#define_singleton_method" do klass.a.should == 42 klass.b(10).should == 20 end - - it "needs to be reviewed for spec completeness" end diff --git a/spec/ruby/core/proc/shared/to_s.rb b/spec/ruby/core/proc/shared/to_s.rb index 46b21dd083..de021692e2 100644 --- a/spec/ruby/core/proc/shared/to_s.rb +++ b/spec/ruby/core/proc/shared/to_s.rb @@ -4,8 +4,8 @@ describe :proc_to_s, shared: true do Proc.new { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)(@([^ ]*)\/to_s\.rb:4)?>$/ end - it "has an ASCII-8BIT encoding" do - Proc.new { "hello" }.send(@method).encoding.should == Encoding::ASCII_8BIT + it "has an BINARY encoding" do + Proc.new { "hello" }.send(@method).encoding.should == Encoding::BINARY end end @@ -14,8 +14,8 @@ describe :proc_to_s, shared: true do lambda { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)(@([^ ]*)\/to_s\.rb:10)? \(lambda\)>$/ end - it "has an ASCII-8BIT encoding" do - lambda { "hello" }.send(@method).encoding.should == Encoding::ASCII_8BIT + it "has an BINARY encoding" do + lambda { "hello" }.send(@method).encoding.should == Encoding::BINARY end end @@ -24,8 +24,8 @@ describe :proc_to_s, shared: true do proc { "hello" }.send(@method).should =~ /^#<Proc:([^ ]*?)(@([^ ]*)\/to_s\.rb:16)?>$/ end - it "has an ASCII-8BIT encoding" do - proc { "hello" }.send(@method).encoding.should == Encoding::ASCII_8BIT + it "has an BINARY encoding" do + proc { "hello" }.send(@method).encoding.should == Encoding::BINARY end end @@ -35,9 +35,9 @@ describe :proc_to_s, shared: true do method("hello").to_proc.send(@method).should =~ /^#<Proc:([^ ]*?)(@([^ ]*)\/to_s\.rb:22)? \(lambda\)>$/ end - it "has an ASCII-8BIT encoding" do + it "has an BINARY encoding" do def hello; end - method("hello").to_proc.send(@method).encoding.should == Encoding::ASCII_8BIT + method("hello").to_proc.send(@method).encoding.should == Encoding::BINARY end end @@ -47,9 +47,9 @@ describe :proc_to_s, shared: true do proc.send(@method).should =~ /^#<Proc:0x\h+\(&:foobar\)>$/ end - it "has an ASCII-8BIT encoding" do + it "has an BINARY encoding" do proc = :foobar.to_proc - proc.send(@method).encoding.should == Encoding::ASCII_8BIT + proc.send(@method).encoding.should == Encoding::BINARY end end end diff --git a/spec/ruby/core/process/fixtures/clocks.rb b/spec/ruby/core/process/fixtures/clocks.rb index 7acc8fbd58..2b4916661c 100644 --- a/spec/ruby/core/process/fixtures/clocks.rb +++ b/spec/ruby/core/process/fixtures/clocks.rb @@ -11,7 +11,7 @@ module ProcessSpecs clocks -= [:CLOCK_BOOTTIME_ALARM, :CLOCK_REALTIME_ALARM] end - clocks.map { |c| + clocks.sort.map { |c| [c, Process.const_get(c)] } end diff --git a/spec/ruby/core/process/getrlimit_spec.rb b/spec/ruby/core/process/getrlimit_spec.rb index 0258bb3d80..d866a48186 100644 --- a/spec/ruby/core/process/getrlimit_spec.rb +++ b/spec/ruby/core/process/getrlimit_spec.rb @@ -41,9 +41,9 @@ platform_is_not :windows do end context "when passed a Symbol" do - Process.constants.grep(/\ARLIMIT_/) do |fullname| - short = $' - it "coerces :#{short} into #{fullname}" do + it "coerces the short name into the full RLIMIT_ prefixed name" do + Process.constants.grep(/\ARLIMIT_/) do |fullname| + short = fullname[/\ARLIMIT_(.+)/, 1] Process.getrlimit(short.to_sym).should == Process.getrlimit(Process.const_get(fullname)) end end @@ -54,9 +54,9 @@ platform_is_not :windows do end context "when passed a String" do - Process.constants.grep(/\ARLIMIT_/) do |fullname| - short = $' - it "coerces '#{short}' into #{fullname}" do + it "coerces the short name into the full RLIMIT_ prefixed name" do + Process.constants.grep(/\ARLIMIT_/) do |fullname| + short = fullname[/\ARLIMIT_(.+)/, 1] Process.getrlimit(short).should == Process.getrlimit(Process.const_get(fullname)) end end diff --git a/spec/ruby/core/process/waitpid_spec.rb b/spec/ruby/core/process/waitpid_spec.rb index fdd6be1287..f7cf1a45a8 100644 --- a/spec/ruby/core/process/waitpid_spec.rb +++ b/spec/ruby/core/process/waitpid_spec.rb @@ -1,8 +1,6 @@ require_relative '../../spec_helper' describe "Process.waitpid" do - it "needs to be reviewed for spec completeness" - it "returns nil when the process has not yet completed and WNOHANG is specified" do pid = spawn("sleep 5") begin diff --git a/spec/ruby/core/random/shared/bytes.rb b/spec/ruby/core/random/shared/bytes.rb index 3485d0f221..54b6b0e4df 100644 --- a/spec/ruby/core/random/shared/bytes.rb +++ b/spec/ruby/core/random/shared/bytes.rb @@ -7,8 +7,8 @@ describe :random_bytes, shared: true do @object.bytes(15).length.should == 15 end - it "returns an ASCII-8BIT String" do - @object.bytes(15).encoding.should == Encoding::ASCII_8BIT + it "returns an BINARY String" do + @object.bytes(15).encoding.should == Encoding::BINARY end it "returns a random binary String" do diff --git a/spec/ruby/core/random/shared/urandom.rb b/spec/ruby/core/random/shared/urandom.rb index f50d30c9de..e5ffcffca6 100644 --- a/spec/ruby/core/random/shared/urandom.rb +++ b/spec/ruby/core/random/shared/urandom.rb @@ -13,8 +13,8 @@ describe :random_urandom, shared: true do }.should raise_error(ArgumentError) end - it "returns an ASCII-8BIT String" do - Random.send(@method, 15).encoding.should == Encoding::ASCII_8BIT + it "returns an BINARY String" do + Random.send(@method, 15).encoding.should == Encoding::BINARY end it "returns a random binary String" do diff --git a/spec/ruby/core/range/cover_spec.rb b/spec/ruby/core/range/cover_spec.rb index 47b75742b2..29c0e0bfa8 100644 --- a/spec/ruby/core/range/cover_spec.rb +++ b/spec/ruby/core/range/cover_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../spec_helper' require_relative 'shared/cover_and_include' require_relative 'shared/cover' diff --git a/spec/ruby/core/range/include_spec.rb b/spec/ruby/core/range/include_spec.rb index e1c5954917..b2c7a54545 100644 --- a/spec/ruby/core/range/include_spec.rb +++ b/spec/ruby/core/range/include_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../spec_helper' require_relative 'shared/cover_and_include' require_relative 'shared/include' diff --git a/spec/ruby/core/range/member_spec.rb b/spec/ruby/core/range/member_spec.rb index ca9deabd35..ab61f92951 100644 --- a/spec/ruby/core/range/member_spec.rb +++ b/spec/ruby/core/range/member_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../spec_helper' require_relative 'shared/cover_and_include' require_relative 'shared/include' diff --git a/spec/ruby/core/range/shared/cover.rb b/spec/ruby/core/range/shared/cover.rb index 7d2367d712..33d416fef5 100644 --- a/spec/ruby/core/range/shared/cover.rb +++ b/spec/ruby/core/range/shared/cover.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' diff --git a/spec/ruby/core/range/shared/cover_and_include.rb b/spec/ruby/core/range/shared/cover_and_include.rb index d3c0700f1a..bed2c77038 100644 --- a/spec/ruby/core/range/shared/cover_and_include.rb +++ b/spec/ruby/core/range/shared/cover_and_include.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' describe :range_cover_and_include, shared: true do diff --git a/spec/ruby/core/range/shared/include.rb b/spec/ruby/core/range/shared/include.rb index b0fc5c2915..c6c5c2becf 100644 --- a/spec/ruby/core/range/shared/include.rb +++ b/spec/ruby/core/range/shared/include.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' diff --git a/spec/ruby/core/regexp/encoding_spec.rb b/spec/ruby/core/regexp/encoding_spec.rb index 1d5bd8890c..6ce6f8b3ca 100644 --- a/spec/ruby/core/regexp/encoding_spec.rb +++ b/spec/ruby/core/regexp/encoding_spec.rb @@ -14,8 +14,8 @@ describe "Regexp#encoding" do /ASCII/n.encoding.should == Encoding::US_ASCII end - it "returns ASCII-8BIT if the 'n' modifier is supplied and non-US-ASCII characters are present" do - /\xc2\xa1/n.encoding.should == Encoding::ASCII_8BIT + it "returns BINARY if the 'n' modifier is supplied and non-US-ASCII characters are present" do + /\xc2\xa1/n.encoding.should == Encoding::BINARY end it "defaults to UTF-8 if \\u escapes appear" do diff --git a/spec/ruby/core/regexp/shared/new.rb b/spec/ruby/core/regexp/shared/new.rb index e8b80ad7c7..ab833ec236 100644 --- a/spec/ruby/core/regexp/shared/new.rb +++ b/spec/ruby/core/regexp/shared/new.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- describe :regexp_new, shared: true do it "requires one argument and creates a new regular expression object" do @@ -135,10 +135,10 @@ describe :regexp_new_string, shared: true do a = "(?:[\x8E\xA1-\xFE])" str = "\A(?:#{a}|x*)\z" - Regexp.send(@method, str, nil, 'N').encoding.should == Encoding::ASCII_8BIT - Regexp.send(@method, str, nil, 'n').encoding.should == Encoding::ASCII_8BIT - Regexp.send(@method, str, nil, 'none').encoding.should == Encoding::ASCII_8BIT - Regexp.send(@method, str, nil, 'NONE').encoding.should == Encoding::ASCII_8BIT + Regexp.send(@method, str, nil, 'N').encoding.should == Encoding::BINARY + Regexp.send(@method, str, nil, 'n').encoding.should == Encoding::BINARY + Regexp.send(@method, str, nil, 'none').encoding.should == Encoding::BINARY + Regexp.send(@method, str, nil, 'NONE').encoding.should == Encoding::BINARY end describe "with escaped characters" do @@ -499,7 +499,7 @@ describe :regexp_new_regexp, shared: true do end it "sets the encoding to source String's encoding if the Regexp literal has the 'n' option and the source String is not ASCII only" do - Regexp.send(@method, Regexp.new("\\xff", nil, 'n')).encoding.should == Encoding::ASCII_8BIT + Regexp.send(@method, Regexp.new("\\xff", nil, 'n')).encoding.should == Encoding::BINARY end end end diff --git a/spec/ruby/core/regexp/shared/quote.rb b/spec/ruby/core/regexp/shared/quote.rb index 016cb0b164..a55adb5bf2 100644 --- a/spec/ruby/core/regexp/shared/quote.rb +++ b/spec/ruby/core/regexp/shared/quote.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- describe :regexp_quote, shared: true do it "escapes any characters with special meaning in a regular expression" do @@ -23,9 +23,9 @@ describe :regexp_quote, shared: true do Regexp.send(@method, str).encoding.should == Encoding::UTF_8 end - it "sets the encoding of the result to ASCII-8BIT if any non-US-ASCII characters are present in an input String with invalid encoding" do + it "sets the encoding of the result to BINARY if any non-US-ASCII characters are present in an input String with invalid encoding" do str = "\xff".force_encoding "us-ascii" str.valid_encoding?.should be_false - Regexp.send(@method, "\xff").encoding.should == Encoding::ASCII_8BIT + Regexp.send(@method, "\xff").encoding.should == Encoding::BINARY end end diff --git a/spec/ruby/core/signal/fixtures/trap_all.rb b/spec/ruby/core/signal/fixtures/trap_all.rb index b2e85df247..afa00b498d 100644 --- a/spec/ruby/core/signal/fixtures/trap_all.rb +++ b/spec/ruby/core/signal/fixtures/trap_all.rb @@ -1,8 +1,15 @@ -reserved_signals = ARGV +cannot_be_trapped = %w[KILL STOP] # See man 2 signal -(Signal.list.keys - reserved_signals).each do |signal| - Signal.trap(signal, -> {}) - Signal.trap(signal, "DEFAULT") +(Signal.list.keys - cannot_be_trapped).each do |signal| + begin + Signal.trap(signal, -> {}) + rescue ArgumentError => e + unless /can't trap reserved signal|Signal already used by VM or OS/ =~ e.message + raise e + end + else + Signal.trap(signal, "DEFAULT") + end end puts "OK" diff --git a/spec/ruby/core/signal/trap_spec.rb b/spec/ruby/core/signal/trap_spec.rb index a3298c71e1..91ce1f1348 100644 --- a/spec/ruby/core/signal/trap_spec.rb +++ b/spec/ruby/core/signal/trap_spec.rb @@ -4,8 +4,7 @@ platform_is_not :windows do describe "Signal.trap" do before :each do ScratchPad.clear - - @proc = lambda { ScratchPad.record :proc_trap } + @proc = -> {} @saved_trap = Signal.trap(:HUP, @proc) end @@ -48,49 +47,34 @@ platform_is_not :windows do ScratchPad.recorded.should be_true end + it "registers an handler doing nothing with :IGNORE" do + Signal.trap :HUP, :IGNORE + Process.kill(:HUP, Process.pid).should == 1 + end + it "ignores the signal when passed nil" do Signal.trap :HUP, nil Signal.trap(:HUP, @saved_trap).should be_nil end - it "accepts 'DEFAULT' as a symbol in place of a proc" do + it "accepts :DEFAULT in place of a proc" do Signal.trap :HUP, :DEFAULT - Signal.trap(:HUP, :DEFAULT).should == "DEFAULT" + Signal.trap(:HUP, @saved_trap).should == "DEFAULT" end - it "accepts 'SIG_DFL' as a symbol in place of a proc" do + it "accepts :SIG_DFL in place of a proc" do Signal.trap :HUP, :SIG_DFL - Signal.trap(:HUP, :SIG_DFL).should == "DEFAULT" + Signal.trap(:HUP, @saved_trap).should == "DEFAULT" end - it "accepts 'SIG_IGN' as a symbol in place of a proc" do + it "accepts :SIG_IGN in place of a proc" do Signal.trap :HUP, :SIG_IGN - Signal.trap(:HUP, :SIG_IGN).should == "IGNORE" + Signal.trap(:HUP, @saved_trap).should == "IGNORE" end - it "accepts 'IGNORE' as a symbol in place of a proc" do + it "accepts :IGNORE in place of a proc" do Signal.trap :HUP, :IGNORE - Signal.trap(:HUP, :IGNORE).should == "IGNORE" - end - - it "accepts long names as Strings" do - Signal.trap "SIGHUP", @proc - Signal.trap("SIGHUP", @saved_trap).should equal(@proc) - end - - it "accepts short names as Strings" do - Signal.trap "HUP", @proc - Signal.trap("HUP", @saved_trap).should equal(@proc) - end - - it "accepts long names as Symbols" do - Signal.trap :SIGHUP, @proc - Signal.trap(:SIGHUP, @saved_trap).should equal(@proc) - end - - it "accepts short names as Symbols" do - Signal.trap :HUP, @proc - Signal.trap(:HUP, @saved_trap).should equal(@proc) + Signal.trap(:HUP, @saved_trap).should == "IGNORE" end it "accepts 'SIG_DFL' in place of a proc" do @@ -105,34 +89,38 @@ platform_is_not :windows do it "accepts 'SIG_IGN' in place of a proc" do Signal.trap :HUP, "SIG_IGN" - Signal.trap(:HUP, "SIG_IGN").should == "IGNORE" + Signal.trap(:HUP, @saved_trap).should == "IGNORE" end it "accepts 'IGNORE' in place of a proc" do Signal.trap :HUP, "IGNORE" - Signal.trap(:HUP, "IGNORE").should == "IGNORE" + Signal.trap(:HUP, @saved_trap).should == "IGNORE" end - end - describe "Signal.trap" do - cannot_be_trapped = %w[KILL STOP] # See man 2 signal - reserved_signals = %w[VTALRM] + it "accepts long names as Strings" do + Signal.trap "SIGHUP", @proc + Signal.trap("SIGHUP", @saved_trap).should equal(@proc) + end - if PlatformGuard.implementation?(:ruby) - reserved_signals += %w[SEGV ILL FPE BUS] + it "accepts short names as Strings" do + Signal.trap "HUP", @proc + Signal.trap("HUP", @saved_trap).should equal(@proc) end - if PlatformGuard.implementation?(:truffleruby) - if !TruffleRuby.native? - reserved_signals += %w[SEGV ILL FPE USR1 QUIT] - end + it "accepts long names as Symbols" do + Signal.trap :SIGHUP, @proc + Signal.trap(:SIGHUP, @saved_trap).should equal(@proc) end - if PlatformGuard.implementation?(:jruby) - reserved_signals += %w[SEGV ILL FPE BUS USR1 QUIT] + it "accepts short names as Symbols" do + Signal.trap :HUP, @proc + Signal.trap(:HUP, @saved_trap).should equal(@proc) end + end - cannot_be_trapped.each do |signal| + describe "Signal.trap" do + # See man 2 signal + %w[KILL STOP].each do |signal| it "raises ArgumentError or Errno::EINVAL for SIG#{signal}" do -> { trap(signal, -> {}) @@ -143,17 +131,8 @@ platform_is_not :windows do end end - reserved_signals.each do |signal| - it "raises ArgumentError for reserved signal: SIG#{signal}" do - -> { - trap(signal, -> {}) - }.should raise_error(ArgumentError, /can't trap reserved signal|Signal already used by VM or OS/) - end - end - - it "allows to register a handler for all known signals, except reserved signals" do - excluded = cannot_be_trapped + reserved_signals - out = ruby_exe(fixture(__FILE__, "trap_all.rb"), args: [*excluded, "2>&1"]) + it "allows to register a handler for all known signals, except reserved signals for which it raises ArgumentError" do + out = ruby_exe(fixture(__FILE__, "trap_all.rb"), args: "2>&1") out.should == "OK\n" $?.exitstatus.should == 0 end diff --git a/spec/ruby/core/string/ascii_only_spec.rb b/spec/ruby/core/string/ascii_only_spec.rb index e9f2dc1a36..c7e02fd874 100644 --- a/spec/ruby/core/string/ascii_only_spec.rb +++ b/spec/ruby/core/string/ascii_only_spec.rb @@ -24,9 +24,9 @@ describe "String#ascii_only?" do end describe "with non-ASCII only characters" do - it "returns false if the encoding is ASCII-8BIT" do + it "returns false if the encoding is BINARY" do chr = 128.chr - chr.encoding.should == Encoding::ASCII_8BIT + chr.encoding.should == Encoding::BINARY chr.ascii_only?.should be_false end diff --git a/spec/ruby/core/string/b_spec.rb b/spec/ruby/core/string/b_spec.rb index 638971f9ce..8555dd8dc7 100644 --- a/spec/ruby/core/string/b_spec.rb +++ b/spec/ruby/core/string/b_spec.rb @@ -2,9 +2,9 @@ require_relative '../../spec_helper' describe "String#b" do - it "returns an ASCII-8BIT encoded string" do - "Hello".b.should == "Hello".force_encoding(Encoding::ASCII_8BIT) - "こんちには".b.should == "こんちには".force_encoding(Encoding::ASCII_8BIT) + it "returns an BINARY encoded string" do + "Hello".b.should == "Hello".force_encoding(Encoding::BINARY) + "こんちには".b.should == "こんちには".force_encoding(Encoding::BINARY) end it "returns new string without modifying self" do diff --git a/spec/ruby/core/string/bytesize_spec.rb b/spec/ruby/core/string/bytesize_spec.rb index b63d718c6c..b8b07cfbec 100644 --- a/spec/ruby/core/string/bytesize_spec.rb +++ b/spec/ruby/core/string/bytesize_spec.rb @@ -3,8 +3,6 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' describe "#String#bytesize" do - it "needs to be reviewed for spec completeness" - it "returns the length of self in bytes" do "hello".bytesize.should == 5 " ".bytesize.should == 1 diff --git a/spec/ruby/core/string/element_set_spec.rb b/spec/ruby/core/string/element_set_spec.rb index f85256d36e..1fdf72ab0f 100644 --- a/spec/ruby/core/string/element_set_spec.rb +++ b/spec/ruby/core/string/element_set_spec.rb @@ -134,9 +134,9 @@ describe "String#[]= with Fixnum index" do it "encodes the String in an encoding compatible with the replacement" do str = " ".force_encoding Encoding::US_ASCII - rep = [160].pack('C').force_encoding Encoding::ASCII_8BIT + rep = [160].pack('C').force_encoding Encoding::BINARY str[0] = rep - str.encoding.should equal(Encoding::ASCII_8BIT) + str.encoding.should equal(Encoding::BINARY) end it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do @@ -190,9 +190,9 @@ describe "String#[]= with String index" do it "encodes the String in an encoding compatible with the replacement" do str = " ".force_encoding Encoding::US_ASCII - rep = [160].pack('C').force_encoding Encoding::ASCII_8BIT + rep = [160].pack('C').force_encoding Encoding::BINARY str[" "] = rep - str.encoding.should equal(Encoding::ASCII_8BIT) + str.encoding.should equal(Encoding::BINARY) end it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do @@ -303,9 +303,9 @@ describe "String#[]= with a Regexp index" do it "encodes the String in an encoding compatible with the replacement" do str = " ".force_encoding Encoding::US_ASCII - rep = [160].pack('C').force_encoding Encoding::ASCII_8BIT + rep = [160].pack('C').force_encoding Encoding::BINARY str[/ /] = rep - str.encoding.should equal(Encoding::ASCII_8BIT) + str.encoding.should equal(Encoding::BINARY) end it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do @@ -424,9 +424,9 @@ describe "String#[]= with a Range index" do it "encodes the String in an encoding compatible with the replacement" do str = " ".force_encoding Encoding::US_ASCII - rep = [160].pack('C').force_encoding Encoding::ASCII_8BIT + rep = [160].pack('C').force_encoding Encoding::BINARY str[0..1] = rep - str.encoding.should equal(Encoding::ASCII_8BIT) + str.encoding.should equal(Encoding::BINARY) end it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do @@ -589,9 +589,9 @@ describe "String#[]= with Fixnum index, count" do it "encodes the String in an encoding compatible with the replacement" do str = " ".force_encoding Encoding::US_ASCII - rep = [160].pack('C').force_encoding Encoding::ASCII_8BIT + rep = [160].pack('C').force_encoding Encoding::BINARY str[0, 1] = rep - str.encoding.should equal(Encoding::ASCII_8BIT) + str.encoding.should equal(Encoding::BINARY) end it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do diff --git a/spec/ruby/core/string/encode_spec.rb b/spec/ruby/core/string/encode_spec.rb index 0be26011ea..67a25aff04 100644 --- a/spec/ruby/core/string/encode_spec.rb +++ b/spec/ruby/core/string/encode_spec.rb @@ -30,7 +30,7 @@ describe "String#encode" do it "encodes an ascii substring of a binary string to UTF-8" do x82 = [0x82].pack('C') - str = "#{x82}foo".force_encoding("ascii-8bit")[1..-1].encode("utf-8") + str = "#{x82}foo".force_encoding("binary")[1..-1].encode("utf-8") str.should == "foo".force_encoding("utf-8") str.encoding.should equal(Encoding::UTF_8) end @@ -60,12 +60,18 @@ describe "String#encode" do "\rfoo".encode(universal_newline: true).should == "\nfoo" end + + it "replaces invalid encoding" do + encoded = "ち\xE3\x81\xFF".encode("UTF-16LE", invalid: :replace, replace: "?") + encoded.should == "\u3061??".encode("UTF-16LE") + encoded.encode("UTF-8").should == "ち??" + end end describe "when passed to, from" do it "returns a copy in the destination encoding when both encodings are the same" do str = "あ" - str.force_encoding("ascii-8bit") + str.force_encoding("binary") encoded = str.encode("utf-8", "utf-8") encoded.should_not equal(str) diff --git a/spec/ruby/core/string/encoding_spec.rb b/spec/ruby/core/string/encoding_spec.rb index 6182e8eb50..4d17a39f29 100644 --- a/spec/ruby/core/string/encoding_spec.rb +++ b/spec/ruby/core/string/encoding_spec.rb @@ -125,13 +125,13 @@ describe "String#encoding for Strings with \\x escapes" do s.encoding.should == Encoding::US_ASCII end - it "returns ASCII-8BIT when an escape creates a byte with the 8th bit set if the source encoding is US-ASCII" do + it "returns BINARY when an escape creates a byte with the 8th bit set if the source encoding is US-ASCII" do __ENCODING__.should == Encoding::US_ASCII str = " " str.encoding.should == Encoding::US_ASCII str += [0xDF].pack('C') str.ascii_only?.should be_false - str.encoding.should == Encoding::ASCII_8BIT + str.encoding.should == Encoding::BINARY end # TODO: Deal with case when the byte in question isn't valid in the source @@ -155,7 +155,7 @@ describe "String#encoding for Strings with \\x escapes" do default_external = Encoding.default_external Encoding.default_external = Encoding::SHIFT_JIS "\x50".encoding.should == Encoding::US_ASCII - [0xD4].pack('C').encoding.should == Encoding::ASCII_8BIT + [0xD4].pack('C').encoding.should == Encoding::BINARY Encoding.default_external = default_external end @@ -166,7 +166,7 @@ describe "String#encoding for Strings with \\x escapes" do Encoding.default_external = Encoding::SHIFT_JIS x50 = "\x50" x50.encoding.should == Encoding::US_ASCII - [0xD4].pack('C').encoding.should == Encoding::ASCII_8BIT + [0xD4].pack('C').encoding.should == Encoding::BINARY Encoding.default_external = default_external Encoding.default_internal = default_internal end diff --git a/spec/ruby/core/string/force_encoding_spec.rb b/spec/ruby/core/string/force_encoding_spec.rb index 83641a37b4..7a5503de56 100644 --- a/spec/ruby/core/string/force_encoding_spec.rb +++ b/spec/ruby/core/string/force_encoding_spec.rb @@ -19,9 +19,9 @@ describe "String#force_encoding" do "abc".force_encoding("internal").encoding.should == Encoding::US_ASCII end - it "defaults to ASCII-8BIT if special encoding name is not set" do + it "defaults to BINARY if special encoding name is not set" do Encoding.default_internal = nil - "abc".force_encoding("internal").encoding.should == Encoding::ASCII_8BIT + "abc".force_encoding("internal").encoding.should == Encoding::BINARY end end diff --git a/spec/ruby/core/string/gsub_spec.rb b/spec/ruby/core/string/gsub_spec.rb index a94010edea..29b65c72a7 100644 --- a/spec/ruby/core/string/gsub_spec.rb +++ b/spec/ruby/core/string/gsub_spec.rb @@ -528,8 +528,8 @@ describe "String#gsub with pattern and block" do s = "hello" s2 = "#{195.chr}#{192.chr}#{195.chr}" - s.gsub(/l/) { |bar| 195.chr }.encoding.should == Encoding::ASCII_8BIT - s2.gsub("#{192.chr}") { |bar| "hello" }.encoding.should == Encoding::ASCII_8BIT + s.gsub(/l/) { |bar| 195.chr }.encoding.should == Encoding::BINARY + s2.gsub("#{192.chr}") { |bar| "hello" }.encoding.should == Encoding::BINARY end it "raises an Encoding::CompatibilityError if the encodings are not compatible" do @@ -653,8 +653,8 @@ describe "String#gsub! with pattern and block" do s = "hello" s2 = "#{195.chr}#{192.chr}#{195.chr}" - s.gsub!(/l/) { |bar| 195.chr }.encoding.should == Encoding::ASCII_8BIT - s2.gsub!("#{192.chr}") { |bar| "hello" }.encoding.should == Encoding::ASCII_8BIT + s.gsub!(/l/) { |bar| 195.chr }.encoding.should == Encoding::BINARY + s2.gsub!("#{192.chr}") { |bar| "hello" }.encoding.should == Encoding::BINARY end it "raises an Encoding::CompatibilityError if the encodings are not compatible" do diff --git a/spec/ruby/core/string/modulo_spec.rb b/spec/ruby/core/string/modulo_spec.rb index 72738ece24..fc4972b9d7 100644 --- a/spec/ruby/core/string/modulo_spec.rb +++ b/spec/ruby/core/string/modulo_spec.rb @@ -21,13 +21,13 @@ describe "String#%" do describe "output's encoding" do it "is the same as the format string if passed value is encoding-compatible" do - [Encoding::ASCII_8BIT, Encoding::US_ASCII, Encoding::UTF_8, Encoding::SHIFT_JIS].each do |encoding| + [Encoding::BINARY, Encoding::US_ASCII, Encoding::UTF_8, Encoding::SHIFT_JIS].each do |encoding| ("hello %s!".encode(encoding) % "world").encoding.should == encoding end end it "negotiates a compatible encoding if necessary" do - ("hello %s" % 195.chr).encoding.should == Encoding::ASCII_8BIT + ("hello %s" % 195.chr).encoding.should == Encoding::BINARY ("hello %s".encode("shift_jis") % "wörld").encoding.should == Encoding::UTF_8 end 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 diff --git a/spec/ruby/core/string/undump_spec.rb b/spec/ruby/core/string/undump_spec.rb index ec13308c16..315d27cad4 100644 --- a/spec/ruby/core/string/undump_spec.rb +++ b/spec/ruby/core/string/undump_spec.rb @@ -430,7 +430,7 @@ ruby_version_is '2.5' do end it "raises RuntimeError if there is malformed dump of non ASCII-compatible string" do - -> { '"".force_encoding("ASCII-8BIT"'.undump }.should raise_error(RuntimeError, /invalid dumped string/) + -> { '"".force_encoding("BINARY"'.undump }.should raise_error(RuntimeError, /invalid dumped string/) -> { '"".force_encoding("Unknown")'.undump }.should raise_error(RuntimeError, /dumped string has unknown encoding name/) -> { '"".force_encoding()'.undump }.should raise_error(RuntimeError, /invalid dumped string/) end diff --git a/spec/ruby/core/string/unpack/a_spec.rb b/spec/ruby/core/string/unpack/a_spec.rb index 3de338e2e1..2d83b4c824 100644 --- a/spec/ruby/core/string/unpack/a_spec.rb +++ b/spec/ruby/core/string/unpack/a_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' @@ -32,7 +32,7 @@ describe "String#unpack with format 'A'" do it "decodes into raw (ascii) string values" do str = "str".force_encoding('UTF-8').unpack("A*")[0] - str.encoding.name.should == 'ASCII-8BIT' + str.encoding.should == Encoding::BINARY end end @@ -60,7 +60,7 @@ describe "String#unpack with format 'a'" do it "decodes into raw (ascii) string values" do str = "".unpack("a*")[0] - str.encoding.name.should == 'ASCII-8BIT' + str.encoding.should == Encoding::BINARY end end diff --git a/spec/ruby/core/string/unpack/at_spec.rb b/spec/ruby/core/string/unpack/at_spec.rb index a5f97b64f0..d8e55a1020 100644 --- a/spec/ruby/core/string/unpack/at_spec.rb +++ b/spec/ruby/core/string/unpack/at_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/string/unpack/b_spec.rb b/spec/ruby/core/string/unpack/b_spec.rb index a0bbc3d421..1a838d6c7c 100644 --- a/spec/ruby/core/string/unpack/b_spec.rb +++ b/spec/ruby/core/string/unpack/b_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/string/unpack/c_spec.rb b/spec/ruby/core/string/unpack/c_spec.rb index bdcbd87663..ed8caa4895 100644 --- a/spec/ruby/core/string/unpack/c_spec.rb +++ b/spec/ruby/core/string/unpack/c_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/string/unpack/comment_spec.rb b/spec/ruby/core/string/unpack/comment_spec.rb index 7e7adbf54f..e18a53df3c 100644 --- a/spec/ruby/core/string/unpack/comment_spec.rb +++ b/spec/ruby/core/string/unpack/comment_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' diff --git a/spec/ruby/core/string/unpack/h_spec.rb b/spec/ruby/core/string/unpack/h_spec.rb index 07d52149d1..f2f5dcf396 100644 --- a/spec/ruby/core/string/unpack/h_spec.rb +++ b/spec/ruby/core/string/unpack/h_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' @@ -63,6 +63,10 @@ describe "String#unpack with format 'H'" do it "ignores spaces between directives" do "\x01\x10".unpack("H H").should == ["0", "1"] end + + it "should make strings with US_ASCII encoding" do + "\x01".unpack("H")[0].encoding.should == Encoding::US_ASCII + end end describe "String#unpack with format 'h'" do @@ -124,4 +128,8 @@ describe "String#unpack with format 'h'" do it "ignores spaces between directives" do "\x01\x10".unpack("h h").should == ["1", "0"] end + + it "should make strings with US_ASCII encoding" do + "\x01".unpack("h")[0].encoding.should == Encoding::US_ASCII + end end diff --git a/spec/ruby/core/string/unpack/m_spec.rb b/spec/ruby/core/string/unpack/m_spec.rb index d714f6fbcb..96841f24cb 100644 --- a/spec/ruby/core/string/unpack/m_spec.rb +++ b/spec/ruby/core/string/unpack/m_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/string/unpack/shared/float.rb b/spec/ruby/core/string/unpack/shared/float.rb index 208dc357af..99bd8a3401 100644 --- a/spec/ruby/core/string/unpack/shared/float.rb +++ b/spec/ruby/core/string/unpack/shared/float.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- describe :string_unpack_float_le, shared: true do it "decodes one float for a single format character" do diff --git a/spec/ruby/core/string/unpack/shared/integer.rb b/spec/ruby/core/string/unpack/shared/integer.rb index 03dfb5c682..cbaa743683 100644 --- a/spec/ruby/core/string/unpack/shared/integer.rb +++ b/spec/ruby/core/string/unpack/shared/integer.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- describe :string_unpack_16bit_le, shared: true do it "decodes one short for a single format character" do diff --git a/spec/ruby/core/string/unpack/u_spec.rb b/spec/ruby/core/string/unpack/u_spec.rb index ee1d6c68e7..8db6de1ab3 100644 --- a/spec/ruby/core/string/unpack/u_spec.rb +++ b/spec/ruby/core/string/unpack/u_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' @@ -31,10 +31,10 @@ describe "String#unpack with format 'u'" do it "decodes into raw (ascii) string values" do str = "".unpack("u")[0] - str.encoding.name.should == 'ASCII-8BIT' + str.encoding.should == Encoding::BINARY str = "1".force_encoding('UTF-8').unpack("u")[0] - str.encoding.name.should == 'ASCII-8BIT' + str.encoding.should == Encoding::BINARY end it "decodes the complete string ignoring newlines when given a single directive" do diff --git a/spec/ruby/core/string/unpack/w_spec.rb b/spec/ruby/core/string/unpack/w_spec.rb index 8ff926783e..166ae58869 100644 --- a/spec/ruby/core/string/unpack/w_spec.rb +++ b/spec/ruby/core/string/unpack/w_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/string/unpack/x_spec.rb b/spec/ruby/core/string/unpack/x_spec.rb index 22b641b732..5adcb720d1 100644 --- a/spec/ruby/core/string/unpack/x_spec.rb +++ b/spec/ruby/core/string/unpack/x_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/string/unpack/z_spec.rb b/spec/ruby/core/string/unpack/z_spec.rb index 2de624a74d..552851ce04 100644 --- a/spec/ruby/core/string/unpack/z_spec.rb +++ b/spec/ruby/core/string/unpack/z_spec.rb @@ -1,4 +1,4 @@ -# -*- encoding: ascii-8bit -*- +# -*- encoding: binary -*- require_relative '../../../spec_helper' require_relative '../fixtures/classes' require_relative 'shared/basic' diff --git a/spec/ruby/core/string/valid_encoding_spec.rb b/spec/ruby/core/string/valid_encoding_spec.rb index 54109386ba..09916df079 100644 --- a/spec/ruby/core/string/valid_encoding_spec.rb +++ b/spec/ruby/core/string/valid_encoding_spec.rb @@ -9,12 +9,12 @@ describe "String#valid_encoding?" do it "returns true if self is valid in the current encoding and other encodings" do str = "\x77" str.force_encoding('utf-8').valid_encoding?.should be_true - str.force_encoding('ascii-8bit').valid_encoding?.should be_true + str.force_encoding('binary').valid_encoding?.should be_true end it "returns true for all encodings self is valid in" do str = "\u{6754}" - str.force_encoding('ASCII-8BIT').valid_encoding?.should be_true + str.force_encoding('BINARY').valid_encoding?.should be_true str.force_encoding('UTF-8').valid_encoding?.should be_true str.force_encoding('US-ASCII').valid_encoding?.should be_false str.force_encoding('Big5').valid_encoding?.should be_false diff --git a/spec/ruby/core/time/shared/now.rb b/spec/ruby/core/time/shared/now.rb index 80f66a1134..d8e5ac9d50 100644 --- a/spec/ruby/core/time/shared/now.rb +++ b/spec/ruby/core/time/shared/now.rb @@ -18,16 +18,18 @@ describe :time_now, shared: true do end end - it "has at least microsecond precision" do - times = [] - 10_000.times do - times << Time.now.nsec - end + guard_not -> { platform_is :windows and ruby_version_is ""..."2.5" } do + it "has at least microsecond precision" do + times = [] + 10_000.times do + times << Time.now.nsec + end - # The clock should not be less accurate than expected (times should - # not all be a multiple of the next precision up, assuming precisions - # are multiples of ten.) - expected = 1_000 - times.select { |t| t % (expected * 10) == 0 }.size.should_not == times.size + # The clock should not be less accurate than expected (times should + # not all be a multiple of the next precision up, assuming precisions + # are multiples of ten.) + expected = 1_000 + times.select { |t| t % (expected * 10) == 0 }.size.should_not == times.size + end end end diff --git a/spec/ruby/core/unboundmethod/hash_spec.rb b/spec/ruby/core/unboundmethod/hash_spec.rb index 2ea8c8d8a6..12dce0020f 100644 --- a/spec/ruby/core/unboundmethod/hash_spec.rb +++ b/spec/ruby/core/unboundmethod/hash_spec.rb @@ -2,8 +2,6 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' describe "UnboundMethod#hash" do - it "needs to be reviewed for spec completeness" - it "returns the same value for user methods that are eql?" do foo, bar = UnboundMethodSpecs::Methods.instance_method(:foo), UnboundMethodSpecs::Methods.instance_method(:bar) foo.hash.should == bar.hash |