aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--lib/cmath.rb2
-rw-r--r--test/test_cmath.rb4
3 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index cab245149d..1370e19a8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Jun 30 06:17:02 2011 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * lib/cmath.rb (CMath.log): second argument: b can be nil.
+
Thu Jun 30 06:23:28 2011 Eric Hodel <drbrain@segment7.net>
* thread.c (ruby_thread_s_pass): Fix typo.
diff --git a/lib/cmath.rb b/lib/cmath.rb
index 74ef41de72..eef1134ef3 100644
--- a/lib/cmath.rb
+++ b/lib/cmath.rb
@@ -71,7 +71,7 @@ module CMath
def log(*args)
begin
z, b = args
- unless b.kind_of?(Numeric)
+ unless b.nil? || b.kind_of?(Numeric)
raise TypeError, "Numeric Number required"
end
if z.real? and z >= 0 and (b.nil? or b >= 0)
diff --git a/test/test_cmath.rb b/test/test_cmath.rb
index 4f85ec3d04..ae4b15cafe 100644
--- a/test/test_cmath.rb
+++ b/test/test_cmath.rb
@@ -6,6 +6,10 @@ class TestCMath < Test::Unit::TestCase
assert_equal CMath.sqrt(1.0.i), CMath.sqrt(1.i), '[ruby-core:31672]'
end
+ def test_acos
+ assert_equal Complex(0.9368124611557199,-2.305509031243477), CMath.acos(Complex(3, 4))
+ end
+
def test_cbrt_returns_principal_value_of_cube_root
assert_equal CMath.cbrt(-8), (-8)**(1.0/3), '#3676'
end