diff --git a/core/integer/round_spec.rb b/core/integer/round_spec.rb index 5cc9aa3881..761c6bb017 100644 --- a/core/integer/round_spec.rb +++ b/core/integer/round_spec.rb @@ -74,4 +74,22 @@ obj.stub!(:to_int).and_return([]) lambda { 42.round(obj) }.should raise_error(TypeError) end + + ruby_version_is "2.4" do + it "returns different rounded values depending on the half option" do + 35.round(1, half: :up).should eql(35.0) + 35.round(1, half: :down).should eql(35.0) + 35.round(1, half: :even).should eql(35.0) + + 25.round(-1, half: :up).should eql(30) + 25.round(-1, half: :down).should eql(20) + 25.round(-1, half: :even).should eql(20) + 35.round(-1, half: :up).should eql(40) + 35.round(-1, half: :down).should eql(30) + 35.round(-1, half: :even).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) + end + end end