Skip to content

Commit

Permalink
Remove all not_compliant_on and deviates_on guards
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
eregon committed Oct 4, 2016
1 parent 66f6ccc commit 4e37db8
Show file tree
Hide file tree
Showing 19 changed files with 92 additions and 263 deletions.
2 changes: 0 additions & 2 deletions TODO
Expand Up @@ -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.
52 changes: 14 additions & 38 deletions core/array/shared/slice.rb
Expand Up @@ -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
12 changes: 2 additions & 10 deletions core/bignum/left_shift_spec.rb
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions core/bignum/right_shift_spec.rb
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions core/exception/no_method_error_spec.rb
Expand Up @@ -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
3 changes: 0 additions & 3 deletions core/file/basename_spec.rb
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions core/file/expand_path_spec.rb
Expand Up @@ -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
Expand Down
18 changes: 3 additions & 15 deletions core/file/split_spec.rb
Expand Up @@ -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

Expand Down
12 changes: 2 additions & 10 deletions core/fixnum/left_shift_spec.rb
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions core/fixnum/right_shift_spec.rb
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions core/io/syswrite_spec.rb
Expand Up @@ -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
Expand Down
23 changes: 5 additions & 18 deletions core/kernel/case_compare_spec.rb
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions core/string/lstrip_spec.rb
Expand Up @@ -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
Expand Down
47 changes: 19 additions & 28 deletions core/string/modulo_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions core/string/sub_spec.rb
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions core/unboundmethod/bind_spec.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 4e37db8

Please sign in to comment.