From d562663e4098801c1d7fa7c64a335ea71231a598 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 25 Apr 2023 17:04:25 +0200 Subject: Update to ruby/spec@7f69c86 --- spec/ruby/core/math/cos_spec.rb | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'spec/ruby/core/math') diff --git a/spec/ruby/core/math/cos_spec.rb b/spec/ruby/core/math/cos_spec.rb index 3ba7a54c38..006afeb2cc 100644 --- a/spec/ruby/core/math/cos_spec.rb +++ b/spec/ruby/core/math/cos_spec.rb @@ -15,7 +15,6 @@ describe "Math.cos" do Math.cos(2*Math::PI).should be_close(1.0, TOLERANCE) end - it "raises a TypeError unless the argument is Numeric and has #to_f" do -> { Math.cos("test") }.should raise_error(TypeError) end @@ -24,14 +23,23 @@ describe "Math.cos" do Math.cos(nan_value).nan?.should be_true end - it "raises a TypeError if the argument is nil" do - -> { Math.cos(nil) }.should raise_error(TypeError) - end - - it "coerces its argument with #to_f" do - f = mock_numeric('8.2') - f.should_receive(:to_f).and_return(8.2) - Math.cos(f).should == Math.cos(8.2) + describe "coerces its argument with #to_f" do + it "coerces its argument with #to_f" do + f = mock_numeric('8.2') + f.should_receive(:to_f).and_return(8.2) + Math.cos(f).should == Math.cos(8.2) + end + + it "raises a TypeError if the given argument can't be converted to a Float" do + -> { Math.cos(nil) }.should raise_error(TypeError) + -> { Math.cos(:abc) }.should raise_error(TypeError) + end + + it "raises a NoMethodError if the given argument raises a NoMethodError during type coercion to a Float" do + object = mock_numeric('mock-float') + object.should_receive(:to_f).and_raise(NoMethodError) + -> { Math.cos(object) }.should raise_error(NoMethodError) + end end end -- cgit v1.2.3