From 3fa5bd38af50fb3d98de0ea51043d73f8d06a24b Mon Sep 17 00:00:00 2001 From: eregon Date: Mon, 29 Jan 2018 16:08:16 +0000 Subject: Update to ruby/spec@83063a3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/core/numeric/coerce_spec.rb | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'spec/ruby/core/numeric/coerce_spec.rb') diff --git a/spec/ruby/core/numeric/coerce_spec.rb b/spec/ruby/core/numeric/coerce_spec.rb index 820d900dd5..63cec4a9b4 100644 --- a/spec/ruby/core/numeric/coerce_spec.rb +++ b/spec/ruby/core/numeric/coerce_spec.rb @@ -29,33 +29,16 @@ describe "Numeric#coerce" do end end - it "calls #to_f to convert other if self responds to #to_f" do - # Do not use NumericSpecs::Subclass here, because coerce checks the classes of the receiver - # and arguments before calling #to_f. - other = mock("numeric") - lambda { @obj.coerce(other) }.should raise_error(TypeError) - end - it "returns [other.to_f, self.to_f] if self and other are instances of different classes" do - result = @obj.coerce(2.5) - result.should == [2.5, 10.5] - result.first.should be_kind_of(Float) - result.last.should be_kind_of(Float) - - result = @obj.coerce(3) - result.should == [3.0, 10.5] - result.first.should be_kind_of(Float) - result.last.should be_kind_of(Float) - - result = @obj.coerce("4.4") - result.should == [4.4, 10.5] - result.first.should be_kind_of(Float) - result.last.should be_kind_of(Float) + @obj.coerce(2.5).should == [2.5, 10.5] + @obj.coerce(3).should == [3.0, 10.5] + @obj.coerce("4.4").should == [4.4, 10.5] + @obj.coerce(bignum_value).should == [bignum_value.to_f, 10.5] + end - result = @obj.coerce(bignum_value) - result.should == [bignum_value.to_f, 10.5] - result.first.should be_kind_of(Float) - result.last.should be_kind_of(Float) + it "raise TypeError if they are instances of different classes and other does not respond to #to_f" do + other = mock("numeric") + lambda { @obj.coerce(other) }.should raise_error(TypeError) end it "raises a TypeError when passed nil" do @@ -70,7 +53,7 @@ describe "Numeric#coerce" do lambda { @obj.coerce(:symbol) }.should raise_error(TypeError) end - it "raises an ArgumentError when passed a String" do + it "raises an ArgumentError when passed a non-numeric String" do lambda { @obj.coerce("test") }.should raise_error(ArgumentError) end end -- cgit v1.2.3