mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@875a09e
This commit is contained in:
parent
a06301b103
commit
5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions
|
@ -16,9 +16,9 @@ describe "Float#round" do
|
|||
end
|
||||
|
||||
it "raises FloatDomainError for exceptional values" do
|
||||
lambda { (+infinity_value).round }.should raise_error(FloatDomainError)
|
||||
lambda { (-infinity_value).round }.should raise_error(FloatDomainError)
|
||||
lambda { nan_value.round }.should raise_error(FloatDomainError)
|
||||
-> { (+infinity_value).round }.should raise_error(FloatDomainError)
|
||||
-> { (-infinity_value).round }.should raise_error(FloatDomainError)
|
||||
-> { nan_value.round }.should raise_error(FloatDomainError)
|
||||
end
|
||||
|
||||
it "rounds self to an optionally given precision" do
|
||||
|
@ -35,20 +35,20 @@ describe "Float#round" do
|
|||
end
|
||||
|
||||
it "raises a TypeError when its argument can not be converted to an Integer" do
|
||||
lambda { 1.0.round("4") }.should raise_error(TypeError)
|
||||
lambda { 1.0.round(nil) }.should raise_error(TypeError)
|
||||
-> { 1.0.round("4") }.should raise_error(TypeError)
|
||||
-> { 1.0.round(nil) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises FloatDomainError for exceptional values when passed a non-positive precision" do
|
||||
lambda { Float::INFINITY.round( 0) }.should raise_error(FloatDomainError)
|
||||
lambda { Float::INFINITY.round(-2) }.should raise_error(FloatDomainError)
|
||||
lambda { (-Float::INFINITY).round( 0) }.should raise_error(FloatDomainError)
|
||||
lambda { (-Float::INFINITY).round(-2) }.should raise_error(FloatDomainError)
|
||||
-> { Float::INFINITY.round( 0) }.should raise_error(FloatDomainError)
|
||||
-> { Float::INFINITY.round(-2) }.should raise_error(FloatDomainError)
|
||||
-> { (-Float::INFINITY).round( 0) }.should raise_error(FloatDomainError)
|
||||
-> { (-Float::INFINITY).round(-2) }.should raise_error(FloatDomainError)
|
||||
end
|
||||
|
||||
it "raises RangeError for NAN when passed a non-positive precision" do
|
||||
lambda { Float::NAN.round(0) }.should raise_error(RangeError)
|
||||
lambda { Float::NAN.round(-2) }.should raise_error(RangeError)
|
||||
-> { Float::NAN.round(0) }.should raise_error(RangeError)
|
||||
-> { Float::NAN.round(-2) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "returns self for exceptional values when passed a non-negative precision" do
|
||||
|
@ -106,12 +106,12 @@ describe "Float#round" do
|
|||
end
|
||||
|
||||
it "raises FloatDomainError for exceptional values with a half option" do
|
||||
lambda { (+infinity_value).round(half: :up) }.should raise_error(FloatDomainError)
|
||||
lambda { (-infinity_value).round(half: :down) }.should raise_error(FloatDomainError)
|
||||
lambda { nan_value.round(half: :even) }.should raise_error(FloatDomainError)
|
||||
-> { (+infinity_value).round(half: :up) }.should raise_error(FloatDomainError)
|
||||
-> { (-infinity_value).round(half: :down) }.should raise_error(FloatDomainError)
|
||||
-> { nan_value.round(half: :even) }.should raise_error(FloatDomainError)
|
||||
end
|
||||
|
||||
it "raise for a non-existent round mode" do
|
||||
lambda { 14.2.round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense")
|
||||
-> { 14.2.round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue