[前][次][番号順一覧][スレッド一覧]

ruby-changes:38738

From: gogotanaka <ko1@a...>
Date: Thu, 11 Jun 2015 05:04:53 +0900 (JST)
Subject: [ruby-changes:38738] gogotanaka:r50819 (trunk): * test/test_cmath.rb: Add assertions for trigonometric functions.

gogotanaka	2015-06-11 05:04:37 +0900 (Thu, 11 Jun 2015)

  New Revision: 50819

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50819

  Log:
    * test/test_cmath.rb: Add assertions for trigonometric functions.

  Modified files:
    trunk/ChangeLog
    trunk/test/test_cmath.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50818)
+++ ChangeLog	(revision 50819)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
 Thu Jun 11 04:34:39 2015  Kazuki Tanaka  <gogotanaka@r...>
 
-	* test/test_cmath.rb: Add assertions for error handling.
+	* test/test_cmath.rb: Add some assertions.
 
 Thu Jun 11 00:34:39 2015  Nobuyoshi Nakada  <nobu@r...>
 
Index: test/test_cmath.rb
===================================================================
--- test/test_cmath.rb	(revision 50818)
+++ test/test_cmath.rb	(revision 50819)
@@ -22,25 +22,45 @@ class TestCMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_cmath.rb#L22
     assert_in_delta 1.092840647090816-0.42078724841586035i, CMath.log(-8, -2)
   end
 
-  def test_functions
-    assert_in_delta -1.1312043837568135+2.4717266720048188i , CMath.exp(1+2i)
+  def test_trigonometric_functions
+    assert_equal CMath.sinh(2).i, CMath.sin(2i)
+    assert_equal CMath.cosh(2),   CMath.cos(2i)
+    assert_equal CMath.tanh(2).i, CMath.tan(2i)
+
+    assert_equal CMath.sin(2).i, CMath.sinh(2i)
+    assert_equal CMath.cos(2),   CMath.cosh(2i)
+    assert_equal CMath.tan(2).i, CMath.tanh(2i)
+
+    assert_in_delta 1+1i, CMath.sin(CMath.asin(1+1i))
+    assert_in_delta 1+1i, CMath.cos(CMath.acos(1+1i))
+    assert_in_delta 1+1i, CMath.tan(CMath.atan(1+1i))
+
+    assert_in_delta 1+1i, CMath.sinh(CMath.asinh(1+1i))
+    assert_in_delta 1+1i, CMath.cosh(CMath.acosh(1+1i))
+    assert_in_delta 1+1i, CMath.tanh(CMath.atanh(1+1i))
+
     assert_in_delta 3.165778513216168+1.959601041421606i    , CMath.sin(1+2i)
     assert_in_delta 2.0327230070196656-3.0518977991517997i  , CMath.cos(1+2i)
     assert_in_delta 0.033812826079896774+1.0147936161466338i, CMath.tan(1+2i)
     assert_in_delta -0.4890562590412937+1.4031192506220405i , CMath.sinh(1+2i)
     assert_in_delta -0.64214812471552+1.0686074213827783i   , CMath.cosh(1+2i)
     assert_in_delta 1.16673625724092-0.2434582011857252i    , CMath.tanh(1+2i)
-    assert_in_delta 1.1609640474436813+1.5972779646881088i  , CMath.log2(1+2i)
-    assert_in_delta 0.3494850021680094+0.480828578784234i   , CMath.log10(1+2i)
     assert_in_delta 0.4270785863924755+1.5285709194809978i  , CMath.asin(1+2i)
     assert_in_delta 1.1437177404024204-1.528570919480998i   , CMath.acos(1+2i)
     assert_in_delta 1.3389725222944935+0.4023594781085251i  , CMath.atan(1+2i)
-    assert_in_delta 1.3389725222944935+0.4023594781085251i  , CMath.atan2(1+2i,1)
     assert_in_delta 1.4693517443681852+1.0634400235777521i  , CMath.asinh(1+2i)
     assert_in_delta 1.528570919480998+1.1437177404024204i   , CMath.acosh(1+2i)
     assert_in_delta 0.17328679513998635+1.1780972450961724i , CMath.atanh(1+2i)
   end
 
+  def test_functions
+    assert_in_delta -1.1312043837568135+2.4717266720048188i, CMath.exp(1+2i)
+    assert_in_delta -1                                     , CMath.exp(Math::PI.i)
+    assert_in_delta 1.1609640474436813+1.5972779646881088i , CMath.log2(1+2i)
+    assert_in_delta 0.3494850021680094+0.480828578784234i  , CMath.log10(1+2i)
+    assert_in_delta 1.3389725222944935+0.4023594781085251i , CMath.atan2(1+2i,1)
+  end
+
   def test_error_handling
     assert_raise_with_message(TypeError, "Numeric Number required") { CMath.acos("2") }
     assert_raise_with_message(TypeError, "Numeric Number required") { CMath.log("2") }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]