From a1b4816759418ca8fe510e8739622fc5d77ab0f0 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 27 Apr 2019 18:53:23 +0200 Subject: Update to ruby/spec@15c9619 --- spec/ruby/shared/rational/Rational.rb | 10 +++---- spec/ruby/shared/rational/round.rb | 49 ++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 27 deletions(-) (limited to 'spec/ruby/shared') diff --git a/spec/ruby/shared/rational/Rational.rb b/spec/ruby/shared/rational/Rational.rb index 30425775d6..3952f663c6 100644 --- a/spec/ruby/shared/rational/Rational.rb +++ b/spec/ruby/shared/rational/Rational.rb @@ -132,12 +132,10 @@ describe :kernel_Rational, shared: true do end end - ruby_bug "#15525", "2.6"..."2.6.1" do - describe "and nil arguments" do - it "swallows an error" do - Rational(nil, exception: false).should == nil - Rational(nil, nil, exception: false).should == nil - end + describe "and nil arguments" do + it "swallows an error" do + Rational(nil, exception: false).should == nil + Rational(nil, nil, exception: false).should == nil end end end diff --git a/spec/ruby/shared/rational/round.rb b/spec/ruby/shared/rational/round.rb index 36ed476350..e99f884cea 100644 --- a/spec/ruby/shared/rational/round.rb +++ b/spec/ruby/shared/rational/round.rb @@ -72,28 +72,35 @@ describe :rational_round, shared: true do end end - ruby_version_is "2.4" do - describe "with half option" do - it "returns an Integer when precision is not passed" do - Rational(10, 4).round(half: :up).should == 3 - Rational(10, 4).round(half: :down).should == 2 - Rational(10, 4).round(half: :even).should == 2 - Rational(-10, 4).round(half: :up).should == -3 - Rational(-10, 4).round(half: :down).should == -2 - Rational(-10, 4).round(half: :even).should == -2 - end + describe "with half option" do + it "returns an Integer when precision is not passed" do + Rational(10, 4).round(half: nil).should == 3 + Rational(10, 4).round(half: :up).should == 3 + Rational(10, 4).round(half: :down).should == 2 + Rational(10, 4).round(half: :even).should == 2 + Rational(-10, 4).round(half: nil).should == -3 + Rational(-10, 4).round(half: :up).should == -3 + Rational(-10, 4).round(half: :down).should == -2 + Rational(-10, 4).round(half: :even).should == -2 + end - it "returns a Rational when the precision is greater than 0" do - Rational(25, 100).round(1, half: :up).should == Rational(3, 10) - Rational(25, 100).round(1, half: :down).should == Rational(1, 5) - Rational(25, 100).round(1, half: :even).should == Rational(1, 5) - Rational(35, 100).round(1, half: :up).should == Rational(2, 5) - Rational(35, 100).round(1, half: :down).should == Rational(3, 10) - Rational(35, 100).round(1, half: :even).should == Rational(2, 5) - Rational(-25, 100).round(1, half: :up).should == Rational(-3, 10) - Rational(-25, 100).round(1, half: :down).should == Rational(-1, 5) - Rational(-25, 100).round(1, half: :even).should == Rational(-1, 5) - end + it "returns a Rational when the precision is greater than 0" do + Rational(25, 100).round(1, half: nil).should == Rational(3, 10) + Rational(25, 100).round(1, half: :up).should == Rational(3, 10) + Rational(25, 100).round(1, half: :down).should == Rational(1, 5) + Rational(25, 100).round(1, half: :even).should == Rational(1, 5) + Rational(35, 100).round(1, half: nil).should == Rational(2, 5) + Rational(35, 100).round(1, half: :up).should == Rational(2, 5) + Rational(35, 100).round(1, half: :down).should == Rational(3, 10) + Rational(35, 100).round(1, half: :even).should == Rational(2, 5) + Rational(-25, 100).round(1, half: nil).should == Rational(-3, 10) + Rational(-25, 100).round(1, half: :up).should == Rational(-3, 10) + Rational(-25, 100).round(1, half: :down).should == Rational(-1, 5) + Rational(-25, 100).round(1, half: :even).should == Rational(-1, 5) + end + + it "raise for a non-existent round mode" do + lambda { Rational(10, 4).round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense") end end end -- cgit v1.2.3