diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
commit | 1d15d5f08032acf1b7bceacbb450d617ff6e0931 (patch) | |
tree | a3785a79899302bc149e4a6e72f624ac27dc1f10 /spec/ruby/library/complex/math/shared/acosh.rb | |
parent | 75bfc6440d595bf339007f4fb280fd4d743e89c1 (diff) |
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
Diffstat (limited to 'spec/ruby/library/complex/math/shared/acosh.rb')
-rw-r--r-- | spec/ruby/library/complex/math/shared/acosh.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/ruby/library/complex/math/shared/acosh.rb b/spec/ruby/library/complex/math/shared/acosh.rb new file mode 100644 index 0000000000..b8be750f13 --- /dev/null +++ b/spec/ruby/library/complex/math/shared/acosh.rb @@ -0,0 +1,37 @@ +require File.expand_path('../../fixtures/classes', __FILE__) + +describe :complex_math_acosh, shared: true do + it "returns the principle value of the inverse hyperbolic cosine of the argument" do + @object.send(:acosh, 14.2).should be_close(3.345146999647, TOLERANCE) + @object.send(:acosh, 1.0).should be_close(0.0, TOLERANCE) + end + + it "returns the principle value of the inverse hyperbolic cosine for numbers less than 1.0 as a Complex number" do + @object.send(:acosh, 1.0 - TOLERANCE).should be_close(Complex(0.0, 0.00774598605746135), TOLERANCE) + @object.send(:acosh, 0).should be_close(Complex(0.0, 1.5707963267949), TOLERANCE) + @object.send(:acosh, -1.0).should be_close(Complex(0.0, 3.14159265358979), TOLERANCE) + end + + it "returns the principle value of the inverse hyperbolic cosine for Complex numbers" do + @object.send(:acosh, Complex(3, 4)) + @object.send(:acosh, Complex(3, 4)).imaginary.should be_close(0.93681246115572, TOLERANCE) + @object.send(:acosh, Complex(3, 4)).real.should be_close(2.305509031243477, TOLERANCE) + end +end + +describe :complex_math_acosh_bang, shared: true do + it "returns the principle value of the inverse hyperbolic cosine of the argument" do + @object.send(:acosh!, 14.2).should be_close(3.345146999647, TOLERANCE) + @object.send(:acosh!, 1.0).should be_close(0.0, TOLERANCE) + end + + it "raises Errno::EDOM for numbers less than 1.0" do + lambda { @object.send(:acosh!, 1.0 - TOLERANCE) }.should raise_error(Errno::EDOM) + lambda { @object.send(:acosh!, 0) }.should raise_error(Errno::EDOM) + lambda { @object.send(:acosh!, -1.0) }.should raise_error(Errno::EDOM) + end + + it "raises a TypeError when passed a Complex number" do + lambda { @object.send(:acosh!, Complex(4, 5)) }.should raise_error(TypeError) + end +end |