1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/shared/math/atanh.rb
eregon 1d15d5f080 Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory.
  [Misc #13792] [ruby-core:82287]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-20 20:18:52 +00:00

44 lines
1.5 KiB
Ruby

describe :math_atanh_base, shared: true do
it "returns a float" do
@object.send(@method, 0.5).should be_an_instance_of(Float)
end
it "returns the inverse hyperbolic tangent of the argument" do
@object.send(@method, 0.0).should == 0.0
@object.send(@method, -0.0).should == -0.0
@object.send(@method, 0.5).should be_close(0.549306144334055, TOLERANCE)
@object.send(@method, -0.2).should be_close(-0.202732554054082, TOLERANCE)
end
it "raises a TypeError if the argument is nil" do
lambda { @object.send(@method, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if the argument is not a Numeric" do
lambda { @object.send(@method, "test") }.should raise_error(TypeError)
end
it "returns Infinity if x == 1.0" do
@object.send(@method, 1.0).should == Float::INFINITY
end
it "return -Infinity if x == -1.0" do
@object.send(@method, -1.0).should == -Float::INFINITY
end
end
describe :math_atanh_private, shared: true do
it "is a private instance method" do
Math.should have_private_instance_method(@method)
end
end
describe :math_atanh_no_complex, shared: true do
it "raises a Math::DomainError for arguments greater than 1.0" do
lambda { @object.send(@method, 1.0 + Float::EPSILON) }.should raise_error(Math::DomainError)
end
it "raises a Math::DomainError for arguments less than -1.0" do
lambda { @object.send(@method, -1.0 - Float::EPSILON) }.should raise_error(Math::DomainError)
end
end