ruby-changes:50471
From: eregon <ko1@a...>
Date: Wed, 28 Feb 2018 05:21:31 +0900 (JST)
Subject: [ruby-changes:50471] eregon:r62602 (trunk): Update to ruby/spec@cbe855c
eregon 2018-02-28 05:21:25 +0900 (Wed, 28 Feb 2018) New Revision: 62602 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62602 Log: Update to ruby/spec@cbe855c Added directories: trunk/spec/ruby/library/erb/fixtures/ Added files: trunk/spec/ruby/library/erb/fixtures/classes.rb Modified files: trunk/spec/ruby/CONTRIBUTING.md trunk/spec/ruby/README.md trunk/spec/ruby/command_line/dash_upper_e_spec.rb trunk/spec/ruby/core/array/clear_spec.rb trunk/spec/ruby/core/array/compact_spec.rb trunk/spec/ruby/core/array/filter_spec.rb trunk/spec/ruby/core/array/reject_spec.rb trunk/spec/ruby/core/array/shared/clone.rb trunk/spec/ruby/core/array/shared/collect.rb trunk/spec/ruby/core/encoding/converter/last_error_spec.rb trunk/spec/ruby/core/encoding/default_external_spec.rb trunk/spec/ruby/core/encoding/default_internal_spec.rb trunk/spec/ruby/core/enumerable/filter_spec.rb trunk/spec/ruby/core/env/shared/to_hash.rb trunk/spec/ruby/core/exception/no_method_error_spec.rb trunk/spec/ruby/core/hash/clone_spec.rb trunk/spec/ruby/core/hash/compare_by_identity_spec.rb trunk/spec/ruby/core/hash/filter_spec.rb trunk/spec/ruby/core/io/read_spec.rb trunk/spec/ruby/core/kernel/Float_spec.rb trunk/spec/ruby/core/kernel/Integer_spec.rb trunk/spec/ruby/core/matchdata/inspect_spec.rb trunk/spec/ruby/core/proc/block_pass_spec.rb trunk/spec/ruby/core/string/chr_spec.rb trunk/spec/ruby/core/string/clear_spec.rb trunk/spec/ruby/core/string/freeze_spec.rb trunk/spec/ruby/core/time/at_spec.rb trunk/spec/ruby/core/time/succ_spec.rb trunk/spec/ruby/language/predefined_spec.rb trunk/spec/ruby/language/string_spec.rb trunk/spec/ruby/library/csv/generate_spec.rb trunk/spec/ruby/library/erb/defmethod/def_erb_method_spec.rb trunk/spec/ruby/library/erb/new_spec.rb trunk/spec/ruby/library/set/filter_spec.rb trunk/spec/ruby/library/set/sortedset/filter_spec.rb trunk/spec/ruby/optional/capi/gc_spec.rb trunk/spec/ruby/optional/capi/string_spec.rb Index: spec/ruby/CONTRIBUTING.md =================================================================== --- spec/ruby/CONTRIBUTING.md (revision 62601) +++ spec/ruby/CONTRIBUTING.md (revision 62602) @@ -158,6 +158,8 @@ guard -> { max_uint <= fixnum_max } do https://github.com/ruby/ruby/blob/trunk/spec/ruby/CONTRIBUTING.md#L158 end ``` +Custom guards are better than a simple `if` as they allow [mspec commands](https://github.com/ruby/mspec/issues/30#issuecomment-312487779) to work properly. + In general, the usage of guards should be minimized as possible. There are no guards to define implementation-specific behavior because Index: spec/ruby/language/string_spec.rb =================================================================== --- spec/ruby/language/string_spec.rb (revision 62601) +++ spec/ruby/language/string_spec.rb (revision 62602) @@ -42,6 +42,15 @@ describe "Ruby character strings" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/string_spec.rb#L42 "#@ip#@ip".should == 'xxxxxx' end + it "don't get confused by partial interpolation character sequences" do + "#@".should == '#@' + "#@ ".should == '#@ ' + "#@@".should == '#@@' + "#@@ ".should == '#@@ ' + "#$ ".should == '#$ ' + "#\$".should == '#$' + end + it "taints the result of interpolation when an interpolated value is tainted" do "#{"".taint}".tainted?.should be_true Index: spec/ruby/language/predefined_spec.rb =================================================================== --- spec/ruby/language/predefined_spec.rb (revision 62601) +++ spec/ruby/language/predefined_spec.rb (revision 62602) @@ -44,11 +44,11 @@ describe "Predefined global $~" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/predefined_spec.rb#L44 it "is set to contain the MatchData object of the last match if successful" do md = /foo/.match 'foo' $~.should be_kind_of(MatchData) - $~.object_id.should == md.object_id + $~.should equal md /bar/ =~ 'bar' $~.should be_kind_of(MatchData) - $~.object_id.should_not == md.object_id + $~.should_not equal md end it "is set to nil if the last match was unsuccessful" do @@ -828,7 +828,7 @@ end https://github.com/ruby/ruby/blob/trunk/spec/ruby/language/predefined_spec.rb#L828 describe "Global variable $\"" do it "is an alias for $LOADED_FEATURES" do - $".object_id.should == $LOADED_FEATURES.object_id + $".should equal $LOADED_FEATURES end it "is read-only" do Index: spec/ruby/optional/capi/string_spec.rb =================================================================== --- spec/ruby/optional/capi/string_spec.rb (revision 62601) +++ spec/ruby/optional/capi/string_spec.rb (revision 62602) @@ -188,7 +188,7 @@ describe "C-API String function" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/string_spec.rb#L188 str1 = "hi" str2 = @s.rb_str_new3 str1 str1.should == str2 - str1.object_id.should_not == str2.object_id + str1.should_not equal str2 end end @@ -217,7 +217,7 @@ describe "C-API String function" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/string_spec.rb#L217 str1 = "hi" str2 = @s.rb_str_dup str1 str1.should == str2 - str1.object_id.should_not == str2.object_id + str1.should_not equal str2 end end Index: spec/ruby/optional/capi/gc_spec.rb =================================================================== --- spec/ruby/optional/capi/gc_spec.rb (revision 62601) +++ spec/ruby/optional/capi/gc_spec.rb (revision 62602) @@ -9,9 +9,9 @@ describe "CApiGCSpecs" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/gc_spec.rb#L9 it "correctly gets the value from a registered address" do @f.registered_tagged_address.should == 10 - @f.registered_tagged_address.object_id.should == @f.registered_tagged_address.object_id + @f.registered_tagged_address.should equal(@f.registered_tagged_address) @f.registered_reference_address.should == "Globally registered data" - @f.registered_reference_address.object_id.should == @f.registered_reference_address.object_id + @f.registered_reference_address.should equal(@f.registered_reference_address) end describe "rb_gc_enable" do Index: spec/ruby/command_line/dash_upper_e_spec.rb =================================================================== --- spec/ruby/command_line/dash_upper_e_spec.rb (revision 62601) +++ spec/ruby/command_line/dash_upper_e_spec.rb (revision 62602) @@ -1,4 +1,29 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/command_line/dash_upper_e_spec.rb#L1 describe "ruby -E" do + it "sets the external encoding with '-E external'" do + result = ruby_exe("print Encoding.default_external", options: '-E euc-jp') + result.should == "EUC-JP" + end + + it "also sets the filesystem encoding with '-E external'" do + result = ruby_exe("print Encoding.find('filesystem')", options: '-E euc-jp') + result.should == "EUC-JP" + end + + it "sets the external encoding with '-E external:'" do + result = ruby_exe("print Encoding.default_external", options: '-E Shift_JIS:') + result.should == "Shift_JIS" + end + + it "sets the internal encoding with '-E :internal'" do + ruby_exe("print Encoding.default_internal", options: '-E :SHIFT_JIS'). + should == 'Shift_JIS' + end + + it "sets the external and internal encodings with '-E external:internal'" do + ruby_exe("puts Encoding.default_external, Encoding.default_internal", options: '-E euc-jp:SHIFT_JIS'). + should == "EUC-JP\nShift_JIS\n" + end + it "raises a RuntimeError if used with -U" do ruby_exe("p 1", options: '-Eascii:ascii -U', Index: spec/ruby/core/proc/block_pass_spec.rb =================================================================== --- spec/ruby/core/proc/block_pass_spec.rb (revision 62601) +++ spec/ruby/core/proc/block_pass_spec.rb (revision 62602) @@ -8,14 +8,14 @@ describe "Proc as a block pass argument" https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/proc/block_pass_spec.rb#L8 it "remains the same object if re-vivified by the target method" do p = Proc.new {} p2 = revivify(&p) - p.object_id.should == p2.object_id + p.should equal p2 p.should == p2 end it "remains the same object if reconstructed with Proc.new" do p = Proc.new {} p2 = Proc.new(&p) - p.object_id.should == p2.object_id + p.should equal p2 p.should == p2 end end @@ -28,14 +28,14 @@ describe "Proc as an implicit block pass https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/proc/block_pass_spec.rb#L28 it "remains the same object if re-vivified by the target method" do p = Proc.new {} p2 = revivify(&p) - p.object_id.should == p2.object_id + p.should equal p2 p.should == p2 end it "remains the same object if reconstructed with Proc.new" do p = Proc.new {} p2 = Proc.new(&p) - p.object_id.should == p2.object_id + p.should equal p2 p.should == p2 end end Index: spec/ruby/core/enumerable/filter_spec.rb =================================================================== --- spec/ruby/core/enumerable/filter_spec.rb (revision 62601) +++ spec/ruby/core/enumerable/filter_spec.rb (revision 62602) @@ -2,6 +2,8 @@ require File.expand_path('../../../spec_ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/enumerable/filter_spec.rb#L2 require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/find_all', __FILE__) -describe "Enumerable#filter" do - it_behaves_like(:enumerable_find_all , :filter) +ruby_version_is "2.6" do + describe "Enumerable#filter" do + it_behaves_like(:enumerable_find_all , :filter) + end end Index: spec/ruby/core/matchdata/inspect_spec.rb =================================================================== --- spec/ruby/core/matchdata/inspect_spec.rb (revision 62601) +++ spec/ruby/core/matchdata/inspect_spec.rb (revision 62602) @@ -14,4 +14,10 @@ describe "MatchData#inspect" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/matchdata/inspect_spec.rb#L14 # it makes perfect sense. See JRUBY-4558 for example. @match_data.inspect.should == '#<MatchData "HX1138" 1:"H" 2:"X" 3:"113" 4:"8">' end + + it "returns a human readable representation of named captures" do + match_data = "abc def ghi".match(/(?<first>\w+)\s+(?<last>\w+)\s+(\w+)/) + + match_data.inspect.should == '#<MatchData "abc def ghi" first:"abc" last:"def">' + end end Index: spec/ruby/core/string/freeze_spec.rb =================================================================== --- spec/ruby/core/string/freeze_spec.rb (revision 62601) +++ spec/ruby/core/string/freeze_spec.rb (revision 62602) @@ -3,12 +3,11 @@ require File.expand_path('../../../spec_ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/string/freeze_spec.rb#L3 describe "String#freeze" do it "produces the same object whenever called on an instance of a literal in the source" do - ids = Array.new(2) { "abc".freeze.object_id } - ids.first.should == ids.last + "abc".freeze.should equal "abc".freeze end it "doesn't produce the same object for different instances of literals in the source" do - "abc".object_id.should_not == "abc".object_id + "abc".should_not equal "abc" end it "being a special form doesn't change the value of defined?" do Index: spec/ruby/core/string/clear_spec.rb =================================================================== --- spec/ruby/core/string/clear_spec.rb (revision 62601) +++ spec/ruby/core/string/clear_spec.rb (revision 62602) @@ -14,7 +14,7 @@ with_feature :encoding do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/string/clear_spec.rb#L14 it "returns self after emptying it" do cleared = @s.clear cleared.should == "" - cleared.object_id.should == @s.object_id + cleared.should equal @s end it "preserves its encoding" do Index: spec/ruby/core/string/chr_spec.rb =================================================================== --- spec/ruby/core/string/chr_spec.rb (revision 62601) +++ spec/ruby/core/string/chr_spec.rb (revision 62602) @@ -4,7 +4,7 @@ with_feature :encoding do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/string/chr_spec.rb#L4 describe "String#chr" do it "returns a copy of self" do s = 'e' - s.object_id.should_not == s.chr.object_id + s.should_not equal s.chr end it "returns a String" do Index: spec/ruby/core/io/read_spec.rb =================================================================== --- spec/ruby/core/io/read_spec.rb (revision 62601) +++ spec/ruby/core/io/read_spec.rb (revision 62602) @@ -257,7 +257,7 @@ describe "IO#read" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/io/read_spec.rb#L257 it "returns the given buffer" do buf = "" - @io.read(nil, buf).object_id.should == buf.object_id + @io.read(nil, buf).should equal buf end it "coerces the second argument to string and uses it as a buffer" do @@ -265,7 +265,7 @@ describe "IO#read" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/io/read_spec.rb#L265 obj = mock("buff") obj.should_receive(:to_str).any_number_of_times.and_return(buf) - @io.read(15, obj).object_id.should_not == obj.object_id + @io.read(15, obj).should_not equal obj buf.should == @contents end Index: spec/ruby/core/array/filter_spec.rb =================================================================== --- spec/ruby/core/array/filter_spec.rb (revision 62601) +++ spec/ruby/core/array/filter_spec.rb (revision 62602) @@ -1,14 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/filter_spec.rb#L1 require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../shared/select', __FILE__) -describe "Array#filter" do - it_behaves_like :array_select, :filter -end - -describe "Array#filter!" do - it "returns nil if no changes were made in the array" do - [1, 2, 3].filter! { true }.should be_nil +ruby_version_is "2.6" do + describe "Array#filter" do + it_behaves_like :array_select, :filter end - it_behaves_like :keep_if, :filter! + describe "Array#filter!" do + it "returns nil if no changes were made in the array" do + [1, 2, 3].filter! { true }.should be_nil + end + + it_behaves_like :keep_if, :filter! + end end Index: spec/ruby/core/array/compact_spec.rb =================================================================== --- spec/ruby/core/array/compact_spec.rb (revision 62601) +++ spec/ruby/core/array/compact_spec.rb (revision 62602) @@ -50,7 +50,7 @@ describe "Array#compact!" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/compact_spec.rb#L50 it "returns self if some nil elements are removed" do a = ['a', nil, 'b', false, 'c'] - a.compact!.object_id.should == a.object_id + a.compact!.should equal a end it "returns nil if there are no nil elements to remove" do Index: spec/ruby/core/array/shared/clone.rb =================================================================== --- spec/ruby/core/array/shared/clone.rb (revision 62601) +++ spec/ruby/core/array/shared/clone.rb (revision 62602) @@ -7,8 +7,8 @@ describe :array_clone, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/clone.rb#L7 it "produces a shallow copy where the references are directly copied" do a = [mock('1'), mock('2')] b = a.send @method - b.first.object_id.should == a.first.object_id - b.last.object_id.should == a.last.object_id + b.first.should equal a.first + b.last.should equal a.last end it "creates a new array containing all elements or the original" do Index: spec/ruby/core/array/shared/collect.rb =================================================================== --- spec/ruby/core/array/shared/collect.rb (revision 62601) +++ spec/ruby/core/array/shared/collect.rb (revision 62602) @@ -5,7 +5,7 @@ describe :array_collect, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/collect.rb#L5 a = ['a', 'b', 'c', 'd'] b = a.send(@method) { |i| i + '!' } b.should == ["a!", "b!", "c!", "d!"] - b.object_id.should_not == a.object_id + b.should_not equal a end it "does not return subclass instance" do @@ -70,7 +70,7 @@ describe :array_collect_b, shared: true https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/shared/collect.rb#L70 it "returns self" do a = [1, 2, 3, 4, 5] b = a.send(@method) {|i| i+1 } - a.object_id.should == b.object_id + a.should equal b end it "returns the evaluated value of block but its contents is partially modified, if it broke in the block" do Index: spec/ruby/core/array/reject_spec.rb =================================================================== --- spec/ruby/core/array/reject_spec.rb (revision 62601) +++ spec/ruby/core/array/reject_spec.rb (revision 62602) @@ -9,9 +9,9 @@ describe "Array#reject" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/reject_spec.rb#L9 ary = [1, 2, 3, 4, 5] ary.reject { true }.should == [] ary.reject { false }.should == ary - ary.reject { false }.object_id.should_not == ary.object_id + ary.reject { false }.should_not equal ary ary.reject { nil }.should == ary - ary.reject { nil }.object_id.should_not == ary.object_id + ary.reject { nil }.should_not equal ary ary.reject { 5 }.should == [] ary.reject { |i| i < 3 }.should == [3, 4, 5] ary.reject { |i| i % 2 == 0 }.should == [1, 3, 5] Index: spec/ruby/core/array/clear_spec.rb =================================================================== --- spec/ruby/core/array/clear_spec.rb (revision 62601) +++ spec/ruby/core/array/clear_spec.rb (revision 62602) @@ -10,8 +10,7 @@ describe "Array#clear" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/array/clear_spec.rb#L10 it "returns self" do a = [1] - oid = a.object_id - a.clear.object_id.should == oid + a.should equal a.clear end it "leaves the Array empty" do Index: spec/ruby/core/kernel/Integer_spec.rb =================================================================== --- spec/ruby/core/kernel/Integer_spec.rb (revision 62601) +++ spec/ruby/core/kernel/Integer_spec.rb (revision 62602) @@ -10,18 +10,29 @@ describe :kernel_integer, shared: true d https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/Integer_spec.rb#L10 Integer(100).should == 100 end - it "raises a TypeError when to_int returns not-an-Integer object and to_i returns nil" do - obj = mock("object") - obj.should_receive(:to_int).and_return("1") - obj.should_receive(:to_i).and_return(nil) - lambda { Integer(obj) }.should raise_error(TypeError) + ruby_version_is ""..."2.6" do + it "uncritically return the value of to_int even if it is not an Integer" do + obj = mock("object") + obj.should_receive(:to_int).and_return("1") + obj.should_not_receive(:to_i) + Integer(obj).should == "1" + end end - it "return a result of to_i when to_int does not return an Integer" do - obj = mock("object") - obj.should_receive(:to_int).and_return("1") - obj.should_receive(:to_i).and_return(42) - Integer(obj).should == 42 + ruby_version_is "2.6" do + it "raises a TypeError when to_int returns not-an-Integer object and to_i returns nil" do + obj = mock("object") + obj.should_receive(:to_int).and_return("1") + obj.should_receive(:to_i).and_return(nil) + lambda { Integer(obj) }.should raise_error(TypeError) + end + + it "return a result of to_i when to_int does not return an Integer" do + obj = mock("object") + obj.should_receive(:to_int).and_return("1") + obj.should_receive(:to_i).and_return(42) + Integer(obj).should == 42 + end end it "raises a TypeError when passed nil" do Index: spec/ruby/core/kernel/Float_spec.rb =================================================================== --- spec/ruby/core/kernel/Float_spec.rb (revision 62601) +++ spec/ruby/core/kernel/Float_spec.rb (revision 62602) @@ -6,7 +6,7 @@ describe :kernel_float, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/Float_spec.rb#L6 float = 1.12 float2 = @object.send(:Float, float) float2.should == float - float2.object_id.should == float.object_id + float2.should equal float end it "returns a Float for Fixnums" do Index: spec/ruby/core/hash/clone_spec.rb =================================================================== --- spec/ruby/core/hash/clone_spec.rb (revision 62601) +++ spec/ruby/core/hash/clone_spec.rb (revision 62602) @@ -7,7 +7,7 @@ describe "Hash#clone" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/hash/clone_spec.rb#L7 clone = hash.clone clone.should == hash - clone.object_id.should_not == hash.object_id + clone.should_not equal hash end end Index: spec/ruby/core/hash/compare_by_identity_spec.rb =================================================================== --- spec/ruby/core/hash/compare_by_identity_spec.rb (revision 62601) +++ spec/ruby/core/hash/compare_by_identity_spec.rb (revision 62602) @@ -105,7 +105,7 @@ describe "Hash#compare_by_identity" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/hash/compare_by_identity_spec.rb#L105 @idh[foo] = true @idh[foo] = true @idh.size.should == 1 - @idh.keys.first.object_id.should == foo.object_id + @idh.keys.first.should equal foo end ruby_bug "#12855", "2.2.0"..."2.4.1" do Index: spec/ruby/core/hash/filter_spec.rb =================================================================== --- spec/ruby/core/hash/filter_spec.rb (revision 62601) +++ spec/ruby/core/hash/filter_spec.rb (revision 62602) @@ -1,10 +1,12 @@ https://github.com/ruby/ruby/blob (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/