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

ruby-changes:38737

From: gogotanaka <ko1@a...>
Date: Thu, 11 Jun 2015 04:40:18 +0900 (JST)
Subject: [ruby-changes:38737] gogotanaka:r50818 (trunk): * test/test_cmath.rb: Add assertions for error handling.

gogotanaka	2015-06-11 04:39:59 +0900 (Thu, 11 Jun 2015)

  New Revision: 50818

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

  Log:
    * test/test_cmath.rb: Add assertions for error handling.

  Modified files:
    trunk/ChangeLog
    trunk/test/test_cmath.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50817)
+++ ChangeLog	(revision 50818)
@@ -1,3 +1,7 @@ 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.
+
 Thu Jun 11 00:34:39 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* template/fake.rb.in: expanded macro result may have spaces
Index: test/test_cmath.rb
===================================================================
--- test/test_cmath.rb	(revision 50817)
+++ test/test_cmath.rb	(revision 50818)
@@ -41,6 +41,14 @@ class TestCMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_cmath.rb#L41
     assert_in_delta 0.17328679513998635+1.1780972450961724i , CMath.atanh(1+2i)
   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") }
+    assert_raise(ArgumentError) { CMath.log(2, "2") }
+    assert_raise(NoMethodError) { CMath.log(2, 2i) }
+    assert_raise(RangeError) { CMath.hypot(2i, 2i) }
+  end
+
   def test_cbrt_returns_principal_value_of_cube_root
     assert_equal (-8)**(1.0/3), CMath.cbrt(-8), '#3676'
   end

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

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