summaryrefslogtreecommitdiff
path: root/spec/ruby/core/numeric/coerce_spec.rb
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-29 16:08:16 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-29 16:08:16 +0000
commit3fa5bd38af50fb3d98de0ea51043d73f8d06a24b (patch)
treed473b71cc6925ee1e17727215e9f9a66e3f24802 /spec/ruby/core/numeric/coerce_spec.rb
parent1e658d45e1f8dbadab18f9c35b5cfb5a5fec98bf (diff)
Update to ruby/spec@83063a3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/numeric/coerce_spec.rb')
-rw-r--r--spec/ruby/core/numeric/coerce_spec.rb35
1 files changed, 9 insertions, 26 deletions
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