From 04df0da508237edf271539c81b352e9d08a3b81a Mon Sep 17 00:00:00 2001 From: Mert Bulan Date: Sat, 7 Oct 2017 12:53:59 +0300 Subject: [PATCH 1/2] Adds specs for Float#ceil, Float#floor, and Float#truncate --- core/float/ceil_spec.rb | 10 ++++++++++ core/float/floor_spec.rb | 10 ++++++++++ core/float/truncate_spec.rb | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/core/float/ceil_spec.rb b/core/float/ceil_spec.rb index 8037164c68..f1d9dcd823 100644 --- a/core/float/ceil_spec.rb +++ b/core/float/ceil_spec.rb @@ -10,4 +10,14 @@ -9223372036854775808.1.ceil.should eql(-9223372036854775808) +9223372036854775808.1.ceil.should eql(+9223372036854775808) end + + ruby_version_is "2.4" do + it "returns the smallest number greater than or equal to self with an optionally given precision" do + 2.1679.ceil(0).should eql(3) + 214.94.ceil(-1).should eql(220) + 7.0.ceil(1).should eql(7.0) + -1.234.ceil(2).should eql(-1.23) + 5.123812.ceil(4).should eql(5.1239) + end + end end diff --git a/core/float/floor_spec.rb b/core/float/floor_spec.rb index 63a5138366..6da5d5c5ee 100644 --- a/core/float/floor_spec.rb +++ b/core/float/floor_spec.rb @@ -10,4 +10,14 @@ -9223372036854775808.1.floor.should eql(-9223372036854775808) +9223372036854775808.1.floor.should eql(+9223372036854775808) end + + ruby_version_is "2.4" do + it "returns the largest number less than or equal to self with an optionally given precision" do + 2.1679.floor(0).should eql(2) + 214.94.floor(-1).should eql(210) + 7.0.floor(1).should eql(7.0) + -1.234.floor(2).should eql(-1.24) + 5.123812.floor(4).should eql(5.1238) + end + end end diff --git a/core/float/truncate_spec.rb b/core/float/truncate_spec.rb index 85ee8ef580..cbb6cdd543 100644 --- a/core/float/truncate_spec.rb +++ b/core/float/truncate_spec.rb @@ -3,4 +3,14 @@ describe "Float#truncate" do it_behaves_like(:float_to_i, :truncate) + + ruby_version_is "2.4" do + it "returns self to an optionally given precision" do + 2.1679.truncate(0).should eql(2) + 7.1.truncate(1).should eql(7.1) + 214.94.truncate(-1).should eql(210) + -1.234.truncate(2).should eql(-1.23) + 5.123812.truncate(4).should eql(5.1238) + end + end end From 39ccb1ae940eff4ba52e7f00f24691f2a87fc2c7 Mon Sep 17 00:00:00 2001 From: Mert Bulan Date: Sat, 7 Oct 2017 14:36:08 +0300 Subject: [PATCH 2/2] Adds the missing truncated --- core/float/truncate_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/float/truncate_spec.rb b/core/float/truncate_spec.rb index cbb6cdd543..7feeb81735 100644 --- a/core/float/truncate_spec.rb +++ b/core/float/truncate_spec.rb @@ -5,7 +5,7 @@ it_behaves_like(:float_to_i, :truncate) ruby_version_is "2.4" do - it "returns self to an optionally given precision" do + it "returns self truncated to an optionally given precision" do 2.1679.truncate(0).should eql(2) 7.1.truncate(1).should eql(7.1) 214.94.truncate(-1).should eql(210)