From 4e37db8ef56b77322cc415b202c68276bca1c4e6 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 4 Oct 2016 23:20:57 +0200 Subject: [PATCH] Remove all not_compliant_on and deviates_on guards * The correct behavior is MRI's or it must be declared as a bug or improved as a feature on the MRI bug tracker. * This project wants to unify behavior, not divide it. --- TODO | 2 - core/array/shared/slice.rb | 52 +++++++----------------- core/bignum/left_shift_spec.rb | 12 +----- core/bignum/right_shift_spec.rb | 12 +----- core/exception/no_method_error_spec.rb | 14 +++---- core/file/basename_spec.rb | 3 -- core/file/expand_path_spec.rb | 12 +----- core/file/split_spec.rb | 18 ++------- core/fixnum/left_shift_spec.rb | 12 +----- core/fixnum/right_shift_spec.rb | 12 +----- core/io/syswrite_spec.rb | 8 ++-- core/kernel/case_compare_spec.rb | 23 +++-------- core/string/lstrip_spec.rb | 7 +--- core/string/modulo_spec.rb | 47 +++++++++------------ core/string/sub_spec.rb | 8 ++-- core/unboundmethod/bind_spec.rb | 8 ---- core/unboundmethod/equal_value_spec.rb | 43 +++++--------------- language/break_spec.rb | 56 +++++++------------------- language/class_spec.rb | 6 +-- 19 files changed, 92 insertions(+), 263 deletions(-) diff --git a/TODO b/TODO index 8226cbfdfc..f81f070d71 100644 --- a/TODO +++ b/TODO @@ -6,5 +6,3 @@ * investigate slow specs (run with -fp) and make them faster. * restore some caller specs from 642bf529 * restore refinements specs and update. See 56c5528f and f20a62e8. -* remove not_compliant_on/deviates_on guards, these specs are - implementation-specific and either should be generalized or removed. diff --git a/core/array/shared/slice.rb b/core/array/shared/slice.rb index 965f8196fa..b3f4ccb9a6 100644 --- a/core/array/shared/slice.rb +++ b/core/array/shared/slice.rb @@ -437,47 +437,23 @@ def to.to_int() -2 end end end - not_compliant_on :rubinius do - it "raises a RangeError when the start index is out of range of Fixnum" do - array = [1, 2, 3, 4, 5, 6] - obj = mock('large value') - obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000) - lambda { array.send(@method, obj) }.should raise_error(RangeError) - - obj = 8e19 - lambda { array.send(@method, obj) }.should raise_error(RangeError) - end - - it "raises a RangeError when the length is out of range of Fixnum" do - array = [1, 2, 3, 4, 5, 6] - obj = mock('large value') - obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000) - lambda { array.send(@method, 1, obj) }.should raise_error(RangeError) + it "raises a RangeError when the start index is out of range of Fixnum" do + array = [1, 2, 3, 4, 5, 6] + obj = mock('large value') + obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000) + lambda { array.send(@method, obj) }.should raise_error(RangeError) - obj = 8e19 - lambda { array.send(@method, 1, obj) }.should raise_error(RangeError) - end + obj = 8e19 + lambda { array.send(@method, obj) }.should raise_error(RangeError) end - deviates_on :rubinius do - it "raises a TypeError when the start index is out of range of Fixnum" do - array = [1, 2, 3, 4, 5, 6] - obj = mock('large value') - obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000) - lambda { array.send(@method, obj) }.should raise_error(TypeError) + it "raises a RangeError when the length is out of range of Fixnum" do + array = [1, 2, 3, 4, 5, 6] + obj = mock('large value') + obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000) + lambda { array.send(@method, 1, obj) }.should raise_error(RangeError) - obj = 8e19 - lambda { array.send(@method, obj) }.should raise_error(TypeError) - end - - it "raises a TypeError when the length is out of range of Fixnum" do - array = [1, 2, 3, 4, 5, 6] - obj = mock('large value') - obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000) - lambda { array.send(@method, 1, obj) }.should raise_error(TypeError) - - obj = 8e19 - lambda { array.send(@method, 1, obj) }.should raise_error(TypeError) - end + obj = 8e19 + lambda { array.send(@method, 1, obj) }.should raise_error(RangeError) end end diff --git a/core/bignum/left_shift_spec.rb b/core/bignum/left_shift_spec.rb index a1c529e821..364f51b708 100644 --- a/core/bignum/left_shift_spec.rb +++ b/core/bignum/left_shift_spec.rb @@ -33,16 +33,8 @@ (@bignum << -68).should == 0 end - not_compliant_on :rubinius, :jruby do - it "returns 0 when m < 0 and m is a Bignum" do - (@bignum << -bignum_value).should == 0 - end - end - - deviates_on :rubinius do - it "raises a RangeError when m < 0 and m is a Bignum" do - lambda { @bignum << -bignum_value }.should raise_error(RangeError) - end + it "returns 0 when m < 0 and m is a Bignum" do + (@bignum << -bignum_value).should == 0 end it "returns a Fixnum == fixnum_max when (fixnum_max * 2) << -1 and n > 0" do diff --git a/core/bignum/right_shift_spec.rb b/core/bignum/right_shift_spec.rb index ec6a92f0e4..d65f7c00a9 100644 --- a/core/bignum/right_shift_spec.rb +++ b/core/bignum/right_shift_spec.rb @@ -59,16 +59,8 @@ (@bignum >> 68).should == 0 end - not_compliant_on :rubinius do - it "returns 0 when m is a Bignum" do - (@bignum >> bignum_value).should == 0 - end - end - - deviates_on :rubinius do - it "raises a RangeError when m is a Bignum" do - lambda { @bignum >> bignum_value }.should raise_error(RangeError) - end + it "returns 0 when m is a Bignum" do + (@bignum >> bignum_value).should == 0 end it "returns a Fixnum == fixnum_max when (fixnum_max * 2) >> 1 and n > 0" do diff --git a/core/exception/no_method_error_spec.rb b/core/exception/no_method_error_spec.rb index ba40e0411c..cf3fe58b1d 100644 --- a/core/exception/no_method_error_spec.rb +++ b/core/exception/no_method_error_spec.rb @@ -48,14 +48,12 @@ end end - not_compliant_on :rubinius do - it "for private method match /private method/" do - begin - NoMethodErrorSpecs::NoMethodErrorC.new.a_private_method - rescue Exception => e - e.should be_kind_of(NoMethodError) - e.message.match(/private method/).should_not == nil - end + it "for private method match /private method/" do + begin + NoMethodErrorSpecs::NoMethodErrorC.new.a_private_method + rescue Exception => e + e.should be_kind_of(NoMethodError) + e.message.match(/private method/).should_not == nil end end end diff --git a/core/file/basename_spec.rb b/core/file/basename_spec.rb index 80998918e0..bf83d43b30 100644 --- a/core/file/basename_spec.rb +++ b/core/file/basename_spec.rb @@ -86,9 +86,6 @@ File.basename("bar.txt", ".*").should == "bar" File.basename("bar.txt.exe", ".*").should == "bar.txt" File.basename("bar.txt.exe", ".txt.exe").should == "bar" - deviates_on :rbx do - File.basename("bar.txt.exe", ".txt.*").should == "bar" - end end it "raises a TypeError if the arguments are not String types" do diff --git a/core/file/expand_path_spec.rb b/core/file/expand_path_spec.rb index bc833c54ad..780859bdf8 100644 --- a/core/file/expand_path_spec.rb +++ b/core/file/expand_path_spec.rb @@ -112,16 +112,8 @@ File.expand_path('~/a','~/b').should == "#{@home}/a" end - not_compliant_on :rubinius, :macruby do - it "does not replace multiple '/' at the beginning of the path" do - File.expand_path('////some/path').should == "////some/path" - end - end - - deviates_on :rubinius, :macruby do - it "replaces multiple '/' with a single '/' at the beginning of the path" do - File.expand_path('////some/path').should == "/some/path" - end + it "does not replace multiple '/' at the beginning of the path" do + File.expand_path('////some/path').should == "////some/path" end it "replaces multiple '/' with a single '/'" do diff --git a/core/file/split_spec.rb b/core/file/split_spec.rb index 34557c8f8a..df271ac51a 100644 --- a/core/file/split_spec.rb +++ b/core/file/split_spec.rb @@ -27,21 +27,9 @@ end platform_is_not os: :windows do - not_compliant_on :jruby do - it "does not split a string that contains '\\'" do - File.split(@backslash).should == [".", "C:\\foo\\bar\\baz"] - File.split(@backslash_ext).should == [".", "C:\\foo\\bar\\baz.rb"] - end - end - - deviates_on :jruby do - it "splits the string at the last '\\' when the last component does not have an extension" do - File.split(@backslash).should == ["C:\\foo\\bar", "baz"] - end - - it "splits the string at the last '\\' when the last component has an extension" do - File.split(@backslash_ext).should == ["C:\\foo\\bar", "baz.rb"] - end + it "does not split a string that contains '\\'" do + File.split(@backslash).should == [".", "C:\\foo\\bar\\baz"] + File.split(@backslash_ext).should == [".", "C:\\foo\\bar\\baz.rb"] end end diff --git a/core/fixnum/left_shift_spec.rb b/core/fixnum/left_shift_spec.rb index 26c46cf0fa..8eb5e424ff 100644 --- a/core/fixnum/left_shift_spec.rb +++ b/core/fixnum/left_shift_spec.rb @@ -51,16 +51,8 @@ (-7 << -64).should == -1 end - not_compliant_on :rubinius, :jruby do - it "returns 0 when m < 0 and m is a Bignum" do - (3 << -bignum_value).should == 0 - end - end - - deviates_on :rubinius do - it "raises a RangeError when m < 0 and m is a Bignum" do - lambda { 3 << -bignum_value }.should raise_error(RangeError) - end + it "returns 0 when m < 0 and m is a Bignum" do + (3 << -bignum_value).should == 0 end it "returns a Bignum == fixnum_max * 2 when fixnum_max << 1 and n > 0" do diff --git a/core/fixnum/right_shift_spec.rb b/core/fixnum/right_shift_spec.rb index 2a08aad71c..9a221ddbe7 100644 --- a/core/fixnum/right_shift_spec.rb +++ b/core/fixnum/right_shift_spec.rb @@ -51,16 +51,8 @@ (-7 >> 64).should == -1 end - not_compliant_on :rubinius do - it "returns 0 when m is a Bignum" do - (3 >> bignum_value).should == 0 - end - end - - deviates_on :rubinius do - it "raises a RangeError when m is a Bignum" do - lambda { 3 >> bignum_value }.should raise_error(RangeError) - end + it "returns 0 when m is a Bignum" do + (3 >> bignum_value).should == 0 end it "returns a Bignum == fixnum_max * 2 when fixnum_max >> -1 and n > 0" do diff --git a/core/io/syswrite_spec.rb b/core/io/syswrite_spec.rb index a32db59d47..879423de2e 100644 --- a/core/io/syswrite_spec.rb +++ b/core/io/syswrite_spec.rb @@ -29,11 +29,9 @@ end end - not_compliant_on :rubinius do - it "warns if called immediately after a buffered IO#write" do - @file.write("abcde") - lambda { @file.syswrite("fghij") }.should complain(/syswrite/) - end + it "warns if called immediately after a buffered IO#write" do + @file.write("abcde") + lambda { @file.syswrite("fghij") }.should complain(/syswrite/) end it "does not warn if called after IO#write with intervening IO#sysread" do diff --git a/core/kernel/case_compare_spec.rb b/core/kernel/case_compare_spec.rb index 20b785666a..9b289984dc 100644 --- a/core/kernel/case_compare_spec.rb +++ b/core/kernel/case_compare_spec.rb @@ -124,26 +124,13 @@ def object_id() @o2 = @o1.dup end - not_compliant_on :rubinius do - it "returns true if the object id is the same even if both #== and #equal? return false" do - @o1.object_id.should == @o1.object_id - - @o1.should_not equal(@o1) - (@o1 == @o1).should == false - - (@o1 === @o1).should == true - end - end - - deviates_on :rubinius do - it "returns false if both #== and #equal? return false even if object id is same" do - @o1.object_id.should == @o1.object_id + it "returns true if the object id is the same even if both #== and #equal? return false" do + @o1.object_id.should == @o1.object_id - @o1.should_not equal(@o1) - (@o1 == @o1).should == false + @o1.should_not equal(@o1) + (@o1 == @o1).should == false - (@o1 === @o1).should == false - end + (@o1 === @o1).should == true end it "returns false if the object id is not the same and both #== and #equal? return false" do diff --git a/core/string/lstrip_spec.rb b/core/string/lstrip_spec.rb index 9d6579cc7c..7ef94be567 100644 --- a/core/string/lstrip_spec.rb +++ b/core/string/lstrip_spec.rb @@ -10,11 +10,8 @@ "\000 \000hello\000 \000".lstrip.should == "\000 \000hello\000 \000" end - # spec/core/string/lstrip_spec.rb - not_compliant_on :rubinius do - it "does not strip leading \\0" do - "\x00hello".lstrip.should == "\x00hello" - end + it "does not strip leading \\0" do + "\x00hello".lstrip.should == "\x00hello" end it "taints the result when self is tainted" do diff --git a/core/string/modulo_spec.rb b/core/string/modulo_spec.rb index e1828d05e6..48c82a2c80 100644 --- a/core/string/modulo_spec.rb +++ b/core/string/modulo_spec.rb @@ -411,29 +411,22 @@ def universal.to_f() 0.0 end ("%*e" % [10, 9]).should == "9.000000e+00" end - # Inf, -Inf, and NaN are identifiers for results of floating point operations - # that cannot be expressed with any value in the set of real numbers. Upcasing - # or downcasing these identifiers for %e or %E, which refers to the case of the - # of the exponent identifier, is silly. - - deviates_on :rubinius, :jruby do - it "supports float formats using %e, but Inf, -Inf, and NaN are not floats" do - ("%e" % 1e1020).should == "Inf" - ("%e" % -1e1020).should == "-Inf" - ("%e" % -Float::NAN).should == "NaN" - ("%e" % Float::NAN).should == "NaN" - end + it "supports float formats using %e, but Inf, -Inf, and NaN are not floats" do + ("%e" % 1e1020).should == "Inf" + ("%e" % -1e1020).should == "-Inf" + ("%e" % -Float::NAN).should == "NaN" + ("%e" % Float::NAN).should == "NaN" + end - it "supports float formats using %E, but Inf, -Inf, and NaN are not floats" do - ("%E" % 1e1020).should == "Inf" - ("%E" % -1e1020).should == "-Inf" - ("%-10E" % 1e1020).should == "Inf " - ("%10E" % 1e1020).should == " Inf" - ("%+E" % 1e1020).should == "+Inf" - ("% E" % 1e1020).should == " Inf" - ("%E" % Float::NAN).should == "NaN" - ("%E" % -Float::NAN).should == "NaN" - end + it "supports float formats using %E, but Inf, -Inf, and NaN are not floats" do + ("%E" % 1e1020).should == "Inf" + ("%E" % -1e1020).should == "-Inf" + ("%-10E" % 1e1020).should == "Inf " + ("%10E" % 1e1020).should == " Inf" + ("%+E" % 1e1020).should == "+Inf" + ("% E" % 1e1020).should == " Inf" + ("%E" % Float::NAN).should == "NaN" + ("%E" % -Float::NAN).should == "NaN" end it "supports float formats using %E" do @@ -447,12 +440,10 @@ def universal.to_f() 0.0 end ("%*E" % [10, 9]).should == "9.000000E+00" end - not_compliant_on :rubinius, :jruby do - it "pads with spaces for %E with Inf, -Inf, and NaN" do - ("%010E" % -1e1020).should == " -Inf" - ("%010E" % 1e1020).should == " Inf" - ("%010E" % Float::NAN).should == " NaN" - end + it "pads with spaces for %E with Inf, -Inf, and NaN" do + ("%010E" % -1e1020).should == " -Inf" + ("%010E" % 1e1020).should == " Inf" + ("%010E" % Float::NAN).should == " NaN" end it "supports float formats using %f" do diff --git a/core/string/sub_spec.rb b/core/string/sub_spec.rb index 28904d660e..9626b3b739 100644 --- a/core/string/sub_spec.rb +++ b/core/string/sub_spec.rb @@ -374,11 +374,9 @@ a.should == "hello" end - not_compliant_on :rubinius do - it "raises a RuntimeError if the string is modified while substituting" do - str = "hello" - lambda { str.sub!(//) { str << 'x' } }.should raise_error(RuntimeError) - end + it "raises a RuntimeError if the string is modified while substituting" do + str = "hello" + lambda { str.sub!(//) { str << 'x' } }.should raise_error(RuntimeError) end it "raises a RuntimeError when self is frozen" do diff --git a/core/unboundmethod/bind_spec.rb b/core/unboundmethod/bind_spec.rb index ee33dc4a25..c1ef10b63d 100644 --- a/core/unboundmethod/bind_spec.rb +++ b/core/unboundmethod/bind_spec.rb @@ -21,14 +21,6 @@ UnboundMethodSpecs::Mod.instance_method(:from_mod).bind(Object.new).should be_kind_of(Method) end - deviates_on :rubinius do - it "returns Method for any object kind_of? the Module the method is defined in" do - @parent_um.bind(UnboundMethodSpecs::Child1.new).should be_kind_of(Method) - @child1_um.bind(UnboundMethodSpecs::Parent.new).should be_kind_of(Method) - @child2_um.bind(UnboundMethodSpecs::Child1.new).should be_kind_of(Method) - end - end - it "Method returned for obj is equal to one directly returned by obj.method" do obj = UnboundMethodSpecs::Methods.new @normal_um.bind(obj).should == obj.method(:foo) diff --git a/core/unboundmethod/equal_value_spec.rb b/core/unboundmethod/equal_value_spec.rb index f938ecc16a..6cf7d87c02 100644 --- a/core/unboundmethod/equal_value_spec.rb +++ b/core/unboundmethod/equal_value_spec.rb @@ -66,24 +66,6 @@ (@child1_alt == @child1).should == true end - # See below for MRI - deviates_on :rubinius do - it "returns true if same method extracted from super- and subclass" do - (@parent == @child1).should == true - (@child1 == @parent).should == true - end - - it "returns true if same method extracted from two different subclasses" do - (@child2 == @child1).should == true - (@child1 == @child2).should == true - end - - it "returns true if same method and the method is defined in an included Module" do - (@includee == @includer).should == true - (@includer == @includee).should == true - end - end - it "returns false if UnboundMethods are different methods" do (@method_one == @method_two).should == false (@method_two == @method_one).should == false @@ -94,22 +76,19 @@ (@identical_body == @original_name).should == false end - # See above for Rubinius - not_compliant_on :rubinius do - it "returns false if same method but one extracted from a subclass" do - (@parent == @child1).should == false - (@child1 == @parent).should == false - end + it "returns false if same method but one extracted from a subclass" do + (@parent == @child1).should == false + (@child1 == @parent).should == false + end - it "returns false if same method but extracted from two different subclasses" do - (@child2 == @child1).should == false - (@child1 == @child2).should == false - end + it "returns false if same method but extracted from two different subclasses" do + (@child2 == @child1).should == false + (@child1 == @child2).should == false + end - it "returns false if methods are the same but added from an included Module" do - (@includee == @includer).should == false - (@includer == @includee).should == false - end + it "returns false if methods are the same but added from an included Module" do + (@includee == @includer).should == false + (@includer == @includee).should == false end it "returns false if both have same Module, same name, identical body but not the same" do diff --git a/language/break_spec.rb b/language/break_spec.rb index f456d955cf..43d14c80b2 100644 --- a/language/break_spec.rb +++ b/language/break_spec.rb @@ -33,38 +33,19 @@ end describe "when the invocation of the scope creating the block is still active" do - deviates_on :rubinius do - it "returns a value to the invoking scope when invoking the block from the scope creating the block" do - @program.break_in_method - ScratchPad.recorded.should == [:a, :xa, :d, :b, :break, :e] - end - - it "returns a value to the scope invoking the method when invoking the block from a method" do - @program.break_in_nested_method - ScratchPad.recorded.should == [:a, :xa, :c, :aa, :b, :break, :d] - end - - it "returns a value to the scope calling the yielding scope when yielding to the block" do - @program.break_in_yielding_method - ScratchPad.recorded.should == [:a, :xa, :c, :aa, :b, :break, :d] - end + it "raises a LocalJumpError when invoking the block from the scope creating the block" do + lambda { @program.break_in_method }.should raise_error(LocalJumpError) + ScratchPad.recorded.should == [:a, :xa, :d, :b] end - not_compliant_on :rubinius do - it "raises a LocalJumpError when invoking the block from the scope creating the block" do - lambda { @program.break_in_method }.should raise_error(LocalJumpError) - ScratchPad.recorded.should == [:a, :xa, :d, :b] - end - - it "raises a LocalJumpError when invoking the block from a method" do - lambda { @program.break_in_nested_method }.should raise_error(LocalJumpError) - ScratchPad.recorded.should == [:a, :xa, :c, :aa, :b] - end + it "raises a LocalJumpError when invoking the block from a method" do + lambda { @program.break_in_nested_method }.should raise_error(LocalJumpError) + ScratchPad.recorded.should == [:a, :xa, :c, :aa, :b] + end - it "raises a LocalJumpError when yielding to the block" do - lambda { @program.break_in_yielding_method }.should raise_error(LocalJumpError) - ScratchPad.recorded.should == [:a, :xa, :c, :aa, :b] - end + it "raises a LocalJumpError when yielding to the block" do + lambda { @program.break_in_yielding_method }.should raise_error(LocalJumpError) + ScratchPad.recorded.should == [:a, :xa, :c, :aa, :b] end end @@ -108,19 +89,10 @@ ScratchPad.recorded.should == [:a, :d, :aa, :aaa, :bb, :b, :break, :cc, :bbb, :dd, :e] end - deviates_on :rubinius do - it "returns a value when yielding to a lambda passed as a block argument" do - @program.break_in_nested_scope_yield - ScratchPad.recorded.should == [:a, :d, :aaa, :b, :break, :e] - end - end - - not_compliant_on :rubinius do - it "raises a LocalJumpError when yielding to a lambda passed as a block argument" do - @program.break_in_nested_scope_yield - expected = [:a, :d, :aaa, :b, :bbb] - ScratchPad.recorded.should == [:a, :d, :aaa, :b, :bbb, :e] - end + it "returns from the lambda" do + @program.break_in_nested_scope_yield + expected = [:a, :d, :aaa, :b, :bbb] + ScratchPad.recorded.should == [:a, :d, :aaa, :b, :bbb, :e] end end diff --git a/language/class_spec.rb b/language/class_spec.rb index e94ba4f0f8..e38e3994f7 100644 --- a/language/class_spec.rb +++ b/language/class_spec.rb @@ -290,10 +290,8 @@ def xyz ClassSpecs.sclass_with_block { 123 }.should == 123 end - not_compliant_on :rubinius do - it "can use return to cause the enclosing method to return" do - ClassSpecs.sclass_with_return.should == :inner - end + it "can use return to cause the enclosing method to return" do + ClassSpecs.sclass_with_return.should == :inner end end