mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@83063a3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1e658d45e1
commit
3fa5bd38af
494 changed files with 4133 additions and 3109 deletions
|
@ -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)
|
||||
it "returns [other.to_f, self.to_f] if self and other are instances of different classes" do
|
||||
@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
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue