aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library/cmath/math/shared/acos.rb
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-09-29 16:03:58 +0200
committerBenoit Daloze <eregontp@gmail.com>2019-09-29 16:03:58 +0200
commit1c938a72aa9378f982dbc55327e86150c47b8707 (patch)
tree34a0bb0a45396c26eed111877a810c3aa793bff5 /spec/ruby/library/cmath/math/shared/acos.rb
parent31bb66a19df26409c9d47afcf37919c9a065516a (diff)
downloadruby-1c938a72aa9378f982dbc55327e86150c47b8707.tar.gz
Update to ruby/spec@519df35
Diffstat (limited to 'spec/ruby/library/cmath/math/shared/acos.rb')
-rw-r--r--spec/ruby/library/cmath/math/shared/acos.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/ruby/library/cmath/math/shared/acos.rb b/spec/ruby/library/cmath/math/shared/acos.rb
new file mode 100644
index 0000000000..65637fa838
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/acos.rb
@@ -0,0 +1,41 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_acos, shared: true do
+ it "returns the arccosine of the passed argument" do
+ @object.send(:acos, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:acos, 0).should be_close(1.5707963267949, TOLERANCE)
+ @object.send(:acos, -1).should be_close(Math::PI,TOLERANCE)
+ end
+
+ it "returns the arccosine for Complex numbers" do
+ @object.send(:acos, Complex(3, 4)).should be_close(Complex(0.93681246115572, -2.30550903124348), TOLERANCE)
+ end
+
+ it "returns the arccosine for numbers greater than 1.0 as a Complex number" do
+ @object.send(:acos, 1.0001).should be_close(Complex(0.0, 0.0141420177752494), TOLERANCE)
+ end
+
+ it "returns the arccosine for numbers less than -1.0 as a Complex number" do
+ @object.send(:acos, -1.0001).should be_close(Complex(3.14159265358979, -0.0141420177752495), TOLERANCE)
+ end
+end
+
+describe :complex_math_acos_bang, shared: true do
+ it "returns the arccosine of the argument" do
+ @object.send(:acos!, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:acos!, 0).should be_close(1.5707963267949, TOLERANCE)
+ @object.send(:acos!, -1).should be_close(Math::PI,TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:acos!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+
+ it "raises an Errno::EDOM for numbers greater than 1.0" do
+ -> { @object.send(:acos!, 1.0001) }.should raise_error(Errno::EDOM)
+ end
+
+ it "raises an Errno::EDOM for numbers less than -1.0" do
+ -> { @object.send(:acos!, -1.0001) }.should raise_error(Errno::EDOM)
+ end
+end