summaryrefslogtreecommitdiff
path: root/spec/ruby/library/cmath
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
parent31bb66a19df26409c9d47afcf37919c9a065516a (diff)
Update to ruby/spec@519df35
Diffstat (limited to 'spec/ruby/library/cmath')
-rw-r--r--spec/ruby/library/cmath/math/acos_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/acosh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/asin_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/asinh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/atan2_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/atan_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/atanh_spec.rb20
-rw-r--r--spec/ruby/library/cmath/math/cos_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/cosh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/exp_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/fixtures/classes.rb4
-rw-r--r--spec/ruby/library/cmath/math/log10_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/log_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/shared/acos.rb41
-rw-r--r--spec/ruby/library/cmath/math/shared/acosh.rb37
-rw-r--r--spec/ruby/library/cmath/math/shared/asin.rb47
-rw-r--r--spec/ruby/library/cmath/math/shared/asinh.rb32
-rw-r--r--spec/ruby/library/cmath/math/shared/atan.rb32
-rw-r--r--spec/ruby/library/cmath/math/shared/atan2.rb34
-rw-r--r--spec/ruby/library/cmath/math/shared/atanh.rb30
-rw-r--r--spec/ruby/library/cmath/math/shared/cos.rb30
-rw-r--r--spec/ruby/library/cmath/math/shared/cosh.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/exp.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/log.rb39
-rw-r--r--spec/ruby/library/cmath/math/shared/log10.rb41
-rw-r--r--spec/ruby/library/cmath/math/shared/sin.rb30
-rw-r--r--spec/ruby/library/cmath/math/shared/sinh.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/sqrt.rb34
-rw-r--r--spec/ruby/library/cmath/math/shared/tan.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/tanh.rb32
-rw-r--r--spec/ruby/library/cmath/math/sin_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/sinh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/sqrt_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/tan_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/tanh_spec.rb18
35 files changed, 883 insertions, 0 deletions
diff --git a/spec/ruby/library/cmath/math/acos_spec.rb b/spec/ruby/library/cmath/math/acos_spec.rb
new file mode 100644
index 0000000000..2e9104f835
--- /dev/null
+++ b/spec/ruby/library/cmath/math/acos_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/acos'
+
+ describe "Math#acos" do
+ it_behaves_like :complex_math_acos, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:acos)
+ end
+ end
+
+ describe "Math.acos" do
+ it_behaves_like :complex_math_acos, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/acosh_spec.rb b/spec/ruby/library/cmath/math/acosh_spec.rb
new file mode 100644
index 0000000000..809112f6c0
--- /dev/null
+++ b/spec/ruby/library/cmath/math/acosh_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/acosh'
+
+ describe "Math#acosh" do
+ it_behaves_like :complex_math_acosh, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:acosh)
+ end
+ end
+
+ describe "Math.acosh" do
+ it_behaves_like :complex_math_acosh, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/asin_spec.rb b/spec/ruby/library/cmath/math/asin_spec.rb
new file mode 100644
index 0000000000..4ac588ebd2
--- /dev/null
+++ b/spec/ruby/library/cmath/math/asin_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/asin'
+
+ describe "Math#asin" do
+ it_behaves_like :complex_math_asin, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:asin)
+ end
+ end
+
+ describe "Math.asin" do
+ it_behaves_like :complex_math_asin, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/asinh_spec.rb b/spec/ruby/library/cmath/math/asinh_spec.rb
new file mode 100644
index 0000000000..7d8b397a04
--- /dev/null
+++ b/spec/ruby/library/cmath/math/asinh_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/asinh'
+
+ describe "Math#asinh" do
+ it_behaves_like :complex_math_asinh, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:asinh)
+ end
+ end
+
+ describe "Math.asinh" do
+ it_behaves_like :complex_math_asinh, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/atan2_spec.rb b/spec/ruby/library/cmath/math/atan2_spec.rb
new file mode 100644
index 0000000000..1a9b7d7607
--- /dev/null
+++ b/spec/ruby/library/cmath/math/atan2_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/atan2'
+
+ describe "Math#atan2" do
+ it_behaves_like :complex_math_atan2, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:atan2)
+ end
+ end
+
+ describe "Math.atan2" do
+ it_behaves_like :complex_math_atan2, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/atan_spec.rb b/spec/ruby/library/cmath/math/atan_spec.rb
new file mode 100644
index 0000000000..b0171081a6
--- /dev/null
+++ b/spec/ruby/library/cmath/math/atan_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/atan'
+
+ describe "Math#atan" do
+ it_behaves_like :complex_math_atan, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:atan)
+ end
+ end
+
+ describe "Math.atan" do
+ it_behaves_like :complex_math_atan, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/atanh_spec.rb b/spec/ruby/library/cmath/math/atanh_spec.rb
new file mode 100644
index 0000000000..6b22c6c9e4
--- /dev/null
+++ b/spec/ruby/library/cmath/math/atanh_spec.rb
@@ -0,0 +1,20 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative '../../../fixtures/math/common'
+ require_relative '../../../shared/math/atanh'
+ require_relative 'shared/atanh'
+
+ describe "Math#atanh" do
+ it_behaves_like :math_atanh_base, :atanh, IncludesMath.new
+ it_behaves_like :complex_math_atanh_complex, :atanh, IncludesMath.new
+
+ it_behaves_like :math_atanh_private, :atanh, IncludesMath.new
+ end
+
+ describe "Math.atanh" do
+ it_behaves_like :math_atanh_base, :atanh, CMath
+ it_behaves_like :complex_math_atanh_complex, :atanh, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/cos_spec.rb b/spec/ruby/library/cmath/math/cos_spec.rb
new file mode 100644
index 0000000000..3f097bcb3b
--- /dev/null
+++ b/spec/ruby/library/cmath/math/cos_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/cos'
+
+ describe "Math#cos" do
+ it_behaves_like :complex_math_cos, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:cos)
+ end
+ end
+
+ describe "Math.cos" do
+ it_behaves_like :complex_math_cos, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/cosh_spec.rb b/spec/ruby/library/cmath/math/cosh_spec.rb
new file mode 100644
index 0000000000..197f899981
--- /dev/null
+++ b/spec/ruby/library/cmath/math/cosh_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/cosh'
+
+ describe "Math#cosh" do
+ it_behaves_like :complex_math_cosh, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:cosh)
+ end
+ end
+
+ describe "Math.cosh" do
+ it_behaves_like :complex_math_cosh, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/exp_spec.rb b/spec/ruby/library/cmath/math/exp_spec.rb
new file mode 100644
index 0000000000..eef2ec3129
--- /dev/null
+++ b/spec/ruby/library/cmath/math/exp_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/exp'
+
+ describe "Math#exp" do
+ it_behaves_like :complex_math_exp, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:exp)
+ end
+ end
+
+ describe "Math.exp" do
+ it_behaves_like :complex_math_exp, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/fixtures/classes.rb b/spec/ruby/library/cmath/math/fixtures/classes.rb
new file mode 100644
index 0000000000..443c1a9ace
--- /dev/null
+++ b/spec/ruby/library/cmath/math/fixtures/classes.rb
@@ -0,0 +1,4 @@
+require 'cmath'
+class IncludesMath
+ include CMath
+end
diff --git a/spec/ruby/library/cmath/math/log10_spec.rb b/spec/ruby/library/cmath/math/log10_spec.rb
new file mode 100644
index 0000000000..603bbb1457
--- /dev/null
+++ b/spec/ruby/library/cmath/math/log10_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/log10'
+
+ describe "Math#log10" do
+ it_behaves_like :complex_math_log10, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:log10)
+ end
+ end
+
+ describe "Math.log10" do
+ it_behaves_like :complex_math_log10, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/log_spec.rb b/spec/ruby/library/cmath/math/log_spec.rb
new file mode 100644
index 0000000000..b4da781323
--- /dev/null
+++ b/spec/ruby/library/cmath/math/log_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/log'
+
+ describe "Math#log" do
+ it_behaves_like :complex_math_log, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:log)
+ end
+ end
+
+ describe "Math.log" do
+ it_behaves_like :complex_math_log, :_, CMath
+ end
+end
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
diff --git a/spec/ruby/library/cmath/math/shared/acosh.rb b/spec/ruby/library/cmath/math/shared/acosh.rb
new file mode 100644
index 0000000000..285b0b823f
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/acosh.rb
@@ -0,0 +1,37 @@
+require_relative '../fixtures/classes'
+
+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
+ -> { @object.send(:acosh!, 1.0 - TOLERANCE) }.should raise_error(Errno::EDOM)
+ -> { @object.send(:acosh!, 0) }.should raise_error(Errno::EDOM)
+ -> { @object.send(:acosh!, -1.0) }.should raise_error(Errno::EDOM)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:acosh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/asin.rb b/spec/ruby/library/cmath/math/shared/asin.rb
new file mode 100644
index 0000000000..91fed7aa06
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/asin.rb
@@ -0,0 +1,47 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_asin, shared: true do
+ it "returns the arcsine of the argument" do
+ @object.send(:asin, 1).should be_close(Math::PI/2, TOLERANCE)
+ @object.send(:asin, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:asin, -1).should be_close(-Math::PI/2, TOLERANCE)
+ @object.send(:asin, 0.25).should be_close(0.252680255142079, TOLERANCE)
+ @object.send(:asin, 0.50).should be_close(0.523598775598299, TOLERANCE)
+ @object.send(:asin, 0.75).should be_close(0.8480620789814816,TOLERANCE)
+ end
+
+ it "returns the arcsine for Complex numbers" do
+ @object.send(:asin, Complex(3, 4)).should be_close(Complex(0.633983865639174, 2.30550903124347), TOLERANCE)
+ end
+
+ it "returns a Complex number when the argument is greater than 1.0" do
+ @object.send(:asin, 1.0001).should be_close(Complex(1.5707963267949, -0.0141420177752494), TOLERANCE)
+ end
+
+ it "returns a Complex number when the argument is less than -1.0" do
+ @object.send(:asin, -1.0001).should be_close(Complex(-1.5707963267949, 0.0141420177752494), TOLERANCE)
+ end
+end
+
+describe :complex_math_asin_bang, shared: true do
+ it "returns the arcsine of the argument" do
+ @object.send(:asin!, 1).should be_close(Math::PI/2, TOLERANCE)
+ @object.send(:asin!, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:asin!, -1).should be_close(-Math::PI/2, TOLERANCE)
+ @object.send(:asin!, 0.25).should be_close(0.252680255142079, TOLERANCE)
+ @object.send(:asin!, 0.50).should be_close(0.523598775598299, TOLERANCE)
+ @object.send(:asin!, 0.75).should be_close(0.8480620789814816,TOLERANCE)
+ end
+
+ it "raises an Errno::EDOM if the argument is greater than 1.0" do
+ -> { @object.send(:asin!, 1.0001) }.should raise_error( Errno::EDOM)
+ end
+
+ it "raises an Errno::EDOM if the argument is less than -1.0" do
+ -> { @object.send(:asin!, -1.0001) }.should raise_error( Errno::EDOM)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:asin!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/asinh.rb b/spec/ruby/library/cmath/math/shared/asinh.rb
new file mode 100644
index 0000000000..b4ddd3a22e
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/asinh.rb
@@ -0,0 +1,32 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_asinh, shared: true do
+ it "returns the inverse hyperbolic sin of the argument" do
+ @object.send(:asinh, 1.5).should be_close(1.19476321728711, TOLERANCE)
+ @object.send(:asinh, -2.97).should be_close(-1.8089166921397, TOLERANCE)
+ @object.send(:asinh, 0.0).should == 0.0
+ @object.send(:asinh, -0.0).should == -0.0
+ @object.send(:asinh, 1.05367e-08).should be_close(1.05367e-08, TOLERANCE)
+ @object.send(:asinh, -1.05367e-08).should be_close(-1.05367e-08, TOLERANCE)
+ end
+
+ it "returns the inverse hyperbolic sin for Complex numbers" do
+ @object.send(:asinh, Complex(3, 4)).should be_close(Complex(2.29991404087927, 0.917616853351479), TOLERANCE)
+ @object.send(:asinh, Complex(3.5, -4)).should be_close(Complex(2.36263337274419, -0.843166327537659), TOLERANCE)
+ end
+end
+
+describe :complex_math_asinh_bang, shared: true do
+ it "returns the inverse hyperbolic sin of the argument" do
+ @object.send(:asinh!, 1.5).should be_close(1.19476321728711, TOLERANCE)
+ @object.send(:asinh!, -2.97).should be_close(-1.8089166921397, TOLERANCE)
+ @object.send(:asinh!, 0.0).should == 0.0
+ @object.send(:asinh!, -0.0).should == -0.0
+ @object.send(:asinh!, 1.05367e-08).should be_close(1.05367e-08, TOLERANCE)
+ @object.send(:asinh!, -1.05367e-08).should be_close(-1.05367e-08, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:asinh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/atan.rb b/spec/ruby/library/cmath/math/shared/atan.rb
new file mode 100644
index 0000000000..63a496e841
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/atan.rb
@@ -0,0 +1,32 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_atan, shared: true do
+ it "returns the arctangent of the argument" do
+ @object.send(:atan, 1).should be_close(Math::PI/4, TOLERANCE)
+ @object.send(:atan, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:atan, -1).should be_close(-Math::PI/4, TOLERANCE)
+ @object.send(:atan, 0.25).should be_close(0.244978663126864, TOLERANCE)
+ @object.send(:atan, 0.50).should be_close(0.463647609000806, TOLERANCE)
+ @object.send(:atan, 0.75).should be_close(0.643501108793284, TOLERANCE)
+ end
+
+ it "returns the arctangent for Complex numbers" do
+ @object.send(:atan, Complex(3, 4)).should be_close(Complex(1.44830699523146, 0.158997191679999), TOLERANCE)
+ @object.send(:atan, Complex(3.5, -4)).should be_close(Complex(1.44507428165589, -0.140323762363786), TOLERANCE)
+ end
+end
+
+describe :complex_math_atan_bang, shared: true do
+ it "returns the arctangent of the argument" do
+ @object.send(:atan!, 1).should be_close(Math::PI/4, TOLERANCE)
+ @object.send(:atan!, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:atan!, -1).should be_close(-Math::PI/4, TOLERANCE)
+ @object.send(:atan!, 0.25).should be_close(0.244978663126864, TOLERANCE)
+ @object.send(:atan!, 0.50).should be_close(0.463647609000806, TOLERANCE)
+ @object.send(:atan!, 0.75).should be_close(0.643501108793284, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:atan!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/atan2.rb b/spec/ruby/library/cmath/math/shared/atan2.rb
new file mode 100644
index 0000000000..6d89423924
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/atan2.rb
@@ -0,0 +1,34 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_atan2, shared: true do
+ it "returns the arc tangent of the passed arguments" do
+ @object.send(:atan2, 4.2, 0.3).should be_close(1.49948886200961, TOLERANCE)
+ @object.send(:atan2, 0.0, 1.0).should be_close(0.0, TOLERANCE)
+ @object.send(:atan2, -9.1, 3.2).should be_close(-1.23265379809025, TOLERANCE)
+ @object.send(:atan2, 7.22, -3.3).should be_close(1.99950888779256, TOLERANCE)
+ end
+
+ it "returns the arc tangent for two Complex numbers" do
+ CMath.atan2(Complex(3, 4), Complex(3.5, -4)).should be_close(Complex(-0.641757436698881, 1.10829873031207), TOLERANCE)
+ end
+
+ it "returns the arc tangent for Complex and real numbers" do
+ CMath.atan2(Complex(3, 4), -7).should be_close(Complex(2.61576754731561, -0.494290673139855), TOLERANCE)
+ CMath.atan2(5, Complex(3.5, -4)).should be_close(Complex(0.739102348493673, 0.487821626522923), TOLERANCE)
+ end
+end
+
+describe :complex_math_atan2_bang, shared: true do
+ it "returns the arc tangent of the passed arguments" do
+ @object.send(:atan2!, 4.2, 0.3).should be_close(1.49948886200961, TOLERANCE)
+ @object.send(:atan2!, 0.0, 1.0).should be_close(0.0, TOLERANCE)
+ @object.send(:atan2!, -9.1, 3.2).should be_close(-1.23265379809025, TOLERANCE)
+ @object.send(:atan2!, 7.22, -3.3).should be_close(1.99950888779256, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:atan2!, Complex(4, 5), Complex(4, 5)) }.should raise_error(TypeError)
+ -> { @object.send(:atan2!, 4, Complex(4, 5)) }.should raise_error(TypeError)
+ -> { @object.send(:atan2!, Complex(4, 5), 5) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/atanh.rb b/spec/ruby/library/cmath/math/shared/atanh.rb
new file mode 100644
index 0000000000..ae80e61bec
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/atanh.rb
@@ -0,0 +1,30 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_atanh_complex, shared: true do
+ it "returns the inverse hyperbolic tangent as a Complex number for arguments greater than 1.0" do
+ value = Complex(18.36840028483855, 1.5707963267948966)
+ @object.send(@method, 1.0 + Float::EPSILON).should be_close(value, TOLERANCE)
+
+ value = Complex(0.100335347731076, 1.5707963267949)
+ @object.send(@method, 10).should be_close(value, TOLERANCE)
+ end
+
+ it "returns the inverse hyperbolic tangent as a Complex number for arguments greater than 1.0" do
+ value = Complex(-18.36840028483855, 1.5707963267948966)
+ @object.send(@method, -1.0 - Float::EPSILON).should be_close(value, TOLERANCE)
+
+ value = Complex(0.100335347731076, 1.5707963267949)
+ @object.send(@method, 10).should be_close(value, TOLERANCE)
+ end
+
+ it "returns the inverse hyperbolic tangent for Complex numbers" do
+ value = Complex(0.117500907311434, 1.40992104959658)
+ @object.send(@method, Complex(3, 4)).should be_close(value, TOLERANCE)
+ end
+end
+
+describe :complex_math_atanh_no_complex, shared: true do
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:atanh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/cos.rb b/spec/ruby/library/cmath/math/shared/cos.rb
new file mode 100644
index 0000000000..31cb5ab1e5
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/cos.rb
@@ -0,0 +1,30 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_cos, shared: true do
+ it "returns the cosine of the argument expressed in radians" do
+ @object.send(:cos, CMath::PI).should be_close(-1.0, TOLERANCE)
+ @object.send(:cos, 0).should be_close(1.0, TOLERANCE)
+ @object.send(:cos, CMath::PI/2).should be_close(0.0, TOLERANCE)
+ @object.send(:cos, 3*Math::PI/2).should be_close(0.0, TOLERANCE)
+ @object.send(:cos, 2*Math::PI).should be_close(1.0, TOLERANCE)
+ end
+
+ it "returns the cosine for Complex numbers" do
+ @object.send(:cos, Complex(0, CMath::PI)).should be_close(Complex(11.5919532755215, 0.0), TOLERANCE)
+ @object.send(:cos, Complex(3, 4)).should be_close(Complex(-27.0349456030742, -3.85115333481178), TOLERANCE)
+ end
+end
+
+describe :complex_math_cos_bang, shared: true do
+ it "returns the cosine of the argument expressed in radians" do
+ @object.send(:cos!, CMath::PI).should be_close(-1.0, TOLERANCE)
+ @object.send(:cos!, 0).should be_close(1.0, TOLERANCE)
+ @object.send(:cos!, CMath::PI/2).should be_close(0.0, TOLERANCE)
+ @object.send(:cos!, 3*Math::PI/2).should be_close(0.0, TOLERANCE)
+ @object.send(:cos!, 2*Math::PI).should be_close(1.0, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:cos!, Complex(3, 4)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/cosh.rb b/spec/ruby/library/cmath/math/shared/cosh.rb
new file mode 100644
index 0000000000..7cf561c985
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/cosh.rb
@@ -0,0 +1,28 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_cosh, shared: true do
+ it "returns the hyperbolic cosine of the passed argument" do
+ @object.send(:cosh, 0.0).should == 1.0
+ @object.send(:cosh, -0.0).should == 1.0
+ @object.send(:cosh, 1.5).should be_close(2.35240961524325, TOLERANCE)
+ @object.send(:cosh, -2.99).should be_close(9.96798496414416, TOLERANCE)
+ end
+
+ it "returns the hyperbolic cosine for Complex numbers" do
+ @object.send(:cosh, Complex(0, CMath::PI)).should be_close(Complex(-1.0, 0.0), TOLERANCE)
+ @object.send(:cosh, Complex(3, 4)).should be_close(Complex(-6.58066304055116, -7.58155274274654), TOLERANCE)
+ end
+end
+
+describe :complex_math_cosh_bang, shared: true do
+ it "returns the hyperbolic cosine of the passed argument" do
+ @object.send(:cosh!, 0.0).should == 1.0
+ @object.send(:cosh!, -0.0).should == 1.0
+ @object.send(:cosh!, 1.5).should be_close(2.35240961524325, TOLERANCE)
+ @object.send(:cosh!, -2.99).should be_close(9.96798496414416, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:cosh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/exp.rb b/spec/ruby/library/cmath/math/shared/exp.rb
new file mode 100644
index 0000000000..6715ac63d3
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/exp.rb
@@ -0,0 +1,28 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_exp, shared: true do
+ it "returns the base-e exponential of the passed argument" do
+ @object.send(:exp, 0.0).should == 1.0
+ @object.send(:exp, -0.0).should == 1.0
+ @object.send(:exp, -1.8).should be_close(0.165298888221587, TOLERANCE)
+ @object.send(:exp, 1.25).should be_close(3.49034295746184, TOLERANCE)
+ end
+
+ it "returns the base-e exponential for Complex numbers" do
+ @object.send(:exp, Complex(0, 0)).should == Complex(1.0, 0.0)
+ @object.send(:exp, Complex(1, 3)).should be_close(Complex(-2.69107861381979, 0.383603953541131), TOLERANCE)
+ end
+end
+
+describe :complex_math_exp_bang, shared: true do
+ it "returns the base-e exponential of the passed argument" do
+ @object.send(:exp!, 0.0).should == 1.0
+ @object.send(:exp!, -0.0).should == 1.0
+ @object.send(:exp!, -1.8).should be_close(0.165298888221587, TOLERANCE)
+ @object.send(:exp!, 1.25).should be_close(3.49034295746184, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:exp!, Complex(1, 3)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/log.rb b/spec/ruby/library/cmath/math/shared/log.rb
new file mode 100644
index 0000000000..4b23e8c5f2
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/log.rb
@@ -0,0 +1,39 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_log, shared: true do
+ it "returns the natural logarithm of the passed argument" do
+ @object.send(:log, 0.0001).should be_close(-9.21034037197618, TOLERANCE)
+ @object.send(:log, 0.000000000001e-15).should be_close(-62.1697975108392, TOLERANCE)
+ @object.send(:log, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:log, 10).should be_close( 2.30258509299405, TOLERANCE)
+ @object.send(:log, 10e15).should be_close(36.8413614879047, TOLERANCE)
+ end
+
+ it "returns the natural logarithm for Complex numbers" do
+ @object.send(:log, Complex(3, 4)).should be_close(Complex(1.6094379124341, 0.927295218001612), TOLERANCE)
+ @object.send(:log, Complex(-3, 4)).should be_close(Complex(1.6094379124341, 2.21429743558818), TOLERANCE)
+ end
+
+ it "returns the natural logarithm for negative numbers as a Complex number" do
+ @object.send(:log, -10).should be_close(Complex(2.30258509299405, 3.14159265358979), TOLERANCE)
+ @object.send(:log, -20).should be_close(Complex(2.99573227355399, 3.14159265358979), TOLERANCE)
+ end
+end
+
+describe :complex_math_log_bang, shared: true do
+ it "returns the natural logarithm of the argument" do
+ @object.send(:log!, 0.0001).should be_close(-9.21034037197618, TOLERANCE)
+ @object.send(:log!, 0.000000000001e-15).should be_close(-62.1697975108392, TOLERANCE)
+ @object.send(:log!, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:log!, 10).should be_close( 2.30258509299405, TOLERANCE)
+ @object.send(:log!, 10e15).should be_close(36.8413614879047, TOLERANCE)
+ end
+
+ it "raises an Errno::EDOM if the argument is less than 0" do
+ -> { @object.send(:log!, -10) }.should raise_error(Errno::EDOM)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:log!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/log10.rb b/spec/ruby/library/cmath/math/shared/log10.rb
new file mode 100644
index 0000000000..f49934d958
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/log10.rb
@@ -0,0 +1,41 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_log10, shared: true do
+ it "returns the base-10 logarithm of the passed argument" do
+ @object.send(:log10, 0.0001).should be_close(-4.0, TOLERANCE)
+ @object.send(:log10, 0.000000000001e-15).should be_close(-27.0, TOLERANCE)
+ @object.send(:log10, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:log10, 10).should be_close(1.0, TOLERANCE)
+ @object.send(:log10, 10e15).should be_close(16.0, TOLERANCE)
+ end
+
+ it "returns the base-10 logarithm for Complex numbers" do
+ @object.send(:log10, Complex(3, 4)).should be_close(Complex(0.698970004336019, 0.402719196273373), TOLERANCE)
+ @object.send(:log10, Complex(-3, 4)).should be_close(Complex(0.698970004336019, 0.961657157568468), TOLERANCE)
+ end
+
+ # BUG: does not work correctly, because Math#log10
+ # does not check for negative values
+ #it "returns the base-10 logarithm for negative numbers as a Complex number" do
+ # @object.send(:log10, -10).should be_close(Complex(2.30258509299405, 3.14159265358979), TOLERANCE)
+ # @object.send(:log10, -20).should be_close(Complex(2.99573227355399, 3.14159265358979), TOLERANCE)
+ #end
+end
+
+describe :complex_math_log10_bang, shared: true do
+ it "returns the base-10 logarithm of the argument" do
+ @object.send(:log10!, 0.0001).should be_close(-4.0, TOLERANCE)
+ @object.send(:log10!, 0.000000000001e-15).should be_close(-27.0, TOLERANCE)
+ @object.send(:log10!, 1).should be_close(0.0, TOLERANCE)
+ @object.send(:log10!, 10).should be_close(1.0, TOLERANCE)
+ @object.send(:log10!, 10e15).should be_close(16.0, TOLERANCE)
+ end
+
+ it "raises an Errno::EDOM when the passed argument is negative" do
+ -> { @object.send(:log10!, -10) }.should raise_error(Errno::EDOM)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:log10!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/sin.rb b/spec/ruby/library/cmath/math/shared/sin.rb
new file mode 100644
index 0000000000..1cb1b29cda
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/sin.rb
@@ -0,0 +1,30 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_sin, shared: true do
+ it "returns the sine of the passed argument expressed in radians" do
+ @object.send(:sin, CMath::PI).should be_close(0.0, TOLERANCE)
+ @object.send(:sin, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:sin, CMath::PI/2).should be_close(1.0, TOLERANCE)
+ @object.send(:sin, 3*Math::PI/2).should be_close(-1.0, TOLERANCE)
+ @object.send(:sin, 2*Math::PI).should be_close(0.0, TOLERANCE)
+ end
+
+ it "returns the sine for Complex numbers" do
+ @object.send(:sin, Complex(0, CMath::PI)).should be_close(Complex(0.0, 11.5487393572577), TOLERANCE)
+ @object.send(:sin, Complex(3, 4)).should be_close(Complex(3.85373803791938, -27.0168132580039), TOLERANCE)
+ end
+end
+
+describe :complex_math_sin_bang, shared: true do
+ it "returns the sine of the passed argument expressed in radians" do
+ @object.send(:sin!, CMath::PI).should be_close(0.0, TOLERANCE)
+ @object.send(:sin!, 0).should be_close(0.0, TOLERANCE)
+ @object.send(:sin!, CMath::PI/2).should be_close(1.0, TOLERANCE)
+ @object.send(:sin!, 3*Math::PI/2).should be_close(-1.0, TOLERANCE)
+ @object.send(:sin!, 2*Math::PI).should be_close(0.0, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:sin!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/sinh.rb b/spec/ruby/library/cmath/math/shared/sinh.rb
new file mode 100644
index 0000000000..de80a376da
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/sinh.rb
@@ -0,0 +1,28 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_sinh, shared: true do
+ it "returns the hyperbolic sin of the argument" do
+ @object.send(:sinh, 0.0).should == 0.0
+ @object.send(:sinh, -0.0).should == 0.0
+ @object.send(:sinh, 1.5).should be_close(2.12927945509482, TOLERANCE)
+ @object.send(:sinh, -2.8).should be_close(-8.19191835423591, TOLERANCE)
+ end
+
+ it "returns the hyperbolic sin for Complex numbers" do
+ @object.send(:sinh, Complex(0, CMath::PI)).should be_close(Complex(-0.0, 1.22464679914735e-16), TOLERANCE)
+ @object.send(:sinh, Complex(3, 4)).should be_close(Complex(-6.548120040911, -7.61923172032141), TOLERANCE)
+ end
+end
+
+describe :complex_math_sinh_bang, shared: true do
+ it "returns the hyperbolic sin of the argument" do
+ @object.send(:sinh!, 0.0).should == 0.0
+ @object.send(:sinh!, -0.0).should == 0.0
+ @object.send(:sinh!, 1.5).should be_close(2.12927945509482, TOLERANCE)
+ @object.send(:sinh!, -2.8).should be_close(-8.19191835423591, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:sinh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/sqrt.rb b/spec/ruby/library/cmath/math/shared/sqrt.rb
new file mode 100644
index 0000000000..23b1ba48ff
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/sqrt.rb
@@ -0,0 +1,34 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_sqrt, shared: true do
+ it "returns the square root for positive numbers" do
+ @object.send(:sqrt, 4).should == 2
+ @object.send(:sqrt, 19.36).should == 4.4
+ end
+
+ it "returns the square root for negative numbers" do
+ @object.send(:sqrt, -4).should == Complex(0, 2.0)
+ @object.send(:sqrt, -19.36).should == Complex(0, 4.4)
+ end
+
+ it "returns the square root for Complex numbers" do
+ @object.send(:sqrt, Complex(4, 5)).should be_close(Complex(2.2806933416653, 1.09615788950152), TOLERANCE)
+ @object.send(:sqrt, Complex(4, -5)).should be_close(Complex(2.2806933416653, -1.09615788950152), TOLERANCE)
+ end
+end
+
+describe :complex_math_sqrt_bang, shared: true do
+ it "returns the square root for positive numbers" do
+ @object.send(:sqrt!, 4).should == 2
+ @object.send(:sqrt!, 19.36).should == 4.4
+ end
+
+ it "raises Errno::EDOM when the passed argument is negative" do
+ -> { @object.send(:sqrt!, -4) }.should raise_error(Errno::EDOM)
+ -> { @object.send(:sqrt!, -19.36) }.should raise_error(Errno::EDOM)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:sqrt!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/tan.rb b/spec/ruby/library/cmath/math/shared/tan.rb
new file mode 100644
index 0000000000..9022c84fc9
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/tan.rb
@@ -0,0 +1,28 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_tan, shared: true do
+ it "returns the tangent of the argument" do
+ @object.send(:tan, 0.0).should == 0.0
+ @object.send(:tan, -0.0).should == -0.0
+ @object.send(:tan, 4.22).should be_close(1.86406937682395, TOLERANCE)
+ @object.send(:tan, -9.65).should be_close(-0.229109052606441, TOLERANCE)
+ end
+
+ it "returns the tangent for Complex numbers" do
+ @object.send(:tan, Complex(0, CMath::PI)).should be_close(Complex(0.0, 0.99627207622075), TOLERANCE)
+ @object.send(:tan, Complex(3, 4)).should be_close(Complex(-0.000187346204629452, 0.999355987381473), TOLERANCE)
+ end
+end
+
+describe :complex_math_tan_bang, shared: true do
+ it "returns the tangent of the argument" do
+ @object.send(:tan!, 0.0).should == 0.0
+ @object.send(:tan!, -0.0).should == -0.0
+ @object.send(:tan!, 4.22).should be_close(1.86406937682395, TOLERANCE)
+ @object.send(:tan!, -9.65).should be_close(-0.229109052606441, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:tan!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/shared/tanh.rb b/spec/ruby/library/cmath/math/shared/tanh.rb
new file mode 100644
index 0000000000..f2c9a5abb1
--- /dev/null
+++ b/spec/ruby/library/cmath/math/shared/tanh.rb
@@ -0,0 +1,32 @@
+require_relative '../fixtures/classes'
+
+describe :complex_math_tanh, shared: true do
+ it "returns the hyperbolic tangent of the argument" do
+ @object.send(:tanh, 0.0).should == 0.0
+ @object.send(:tanh, -0.0).should == -0.0
+ @object.send(:tanh, infinity_value).should == 1.0
+ @object.send(:tanh, -infinity_value).should == -1.0
+ @object.send(:tanh, 2.5).should be_close(0.98661429815143, TOLERANCE)
+ @object.send(:tanh, -4.892).should be_close(-0.999887314427707, TOLERANCE)
+ end
+
+ it "returns the hyperbolic tangent for Complex numbers" do
+ @object.send(:tanh, Complex(0, CMath::PI)).should be_close(Complex(0.0, -1.22464679914735e-16), TOLERANCE)
+ @object.send(:tanh, Complex(3, 4)).should be_close(Complex(1.00070953606723, 0.00490825806749599), TOLERANCE)
+ end
+end
+
+describe :complex_math_tanh_bang, shared: true do
+ it "returns the hyperbolic tangent of the argument" do
+ @object.send(:tanh!, 0.0).should == 0.0
+ @object.send(:tanh!, -0.0).should == -0.0
+ @object.send(:tanh!, infinity_value).should == 1.0
+ @object.send(:tanh!, -infinity_value).should == -1.0
+ @object.send(:tanh!, 2.5).should be_close(0.98661429815143, TOLERANCE)
+ @object.send(:tanh!, -4.892).should be_close(-0.999887314427707, TOLERANCE)
+ end
+
+ it "raises a TypeError when passed a Complex number" do
+ -> { @object.send(:tanh!, Complex(4, 5)) }.should raise_error(TypeError)
+ end
+end
diff --git a/spec/ruby/library/cmath/math/sin_spec.rb b/spec/ruby/library/cmath/math/sin_spec.rb
new file mode 100644
index 0000000000..b7a219fbbd
--- /dev/null
+++ b/spec/ruby/library/cmath/math/sin_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/sin'
+
+ describe "Math#sin" do
+ it_behaves_like :complex_math_sin, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:sin)
+ end
+ end
+
+ describe "Math.sin" do
+ it_behaves_like :complex_math_sin, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/sinh_spec.rb b/spec/ruby/library/cmath/math/sinh_spec.rb
new file mode 100644
index 0000000000..c6e6a3baf4
--- /dev/null
+++ b/spec/ruby/library/cmath/math/sinh_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/sinh'
+
+ describe "Math#sinh" do
+ it_behaves_like :complex_math_sinh, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:sinh)
+ end
+ end
+
+ describe "Math.sinh" do
+ it_behaves_like :complex_math_sinh, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/sqrt_spec.rb b/spec/ruby/library/cmath/math/sqrt_spec.rb
new file mode 100644
index 0000000000..421824f99c
--- /dev/null
+++ b/spec/ruby/library/cmath/math/sqrt_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/sqrt'
+
+ describe "Math#sqrt" do
+ it_behaves_like :complex_math_sqrt, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:sqrt)
+ end
+ end
+
+ describe "Math.sqrt" do
+ it_behaves_like :complex_math_sqrt, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/tan_spec.rb b/spec/ruby/library/cmath/math/tan_spec.rb
new file mode 100644
index 0000000000..e2acdd8091
--- /dev/null
+++ b/spec/ruby/library/cmath/math/tan_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/tan'
+
+ describe "Math#tan" do
+ it_behaves_like :complex_math_tan, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:tan)
+ end
+ end
+
+ describe "Math.tan" do
+ it_behaves_like :complex_math_tan, :_, CMath
+ end
+end
diff --git a/spec/ruby/library/cmath/math/tanh_spec.rb b/spec/ruby/library/cmath/math/tanh_spec.rb
new file mode 100644
index 0000000000..94da20cd51
--- /dev/null
+++ b/spec/ruby/library/cmath/math/tanh_spec.rb
@@ -0,0 +1,18 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is ''...'2.7' do
+ require 'complex'
+ require_relative 'shared/tanh'
+
+ describe "Math#tanh" do
+ it_behaves_like :complex_math_tanh, :_, IncludesMath.new
+
+ it "is a private instance method" do
+ IncludesMath.should have_private_instance_method(:tanh)
+ end
+ end
+
+ describe "Math.tanh" do
+ it_behaves_like :complex_math_tanh, :_, CMath
+ end
+end