From 80119090e7cd9071cb52905f13d52ca56b5a340d Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Sat, 7 Oct 2017 16:28:11 +0200 Subject: [PATCH] Add spec for Float#round(half:) --- core/float/round_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/float/round_spec.rb b/core/float/round_spec.rb index 46d23b36d0..56668d5856 100644 --- a/core/float/round_spec.rb +++ b/core/float/round_spec.rb @@ -84,4 +84,18 @@ -2.5e200.round(-200).should eql( -3 * 10 ** 200 ) -2.4e200.round(-200).should eql( -2 * 10 ** 200 ) end + + ruby_version_is "2.4" do + it "returns different rounded values depending on the half option" do + 2.5.round(half: :up).should eql(3) + 2.5.round(half: :down).should eql(2) + 2.5.round(half: :even).should eql(2) + 3.5.round(half: :up).should eql(4) + 3.5.round(half: :down).should eql(3) + 3.5.round(half: :even).should eql(4) + (-2.5).round(half: :up).should eql(-3) + (-2.5).round(half: :down).should eql(-2) + (-2.5).round(half: :even).should eql(-2) + end + end end