From eaa572e57d1a21892e57f7e451cb991fab32b2d2 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 29 Jun 2011 21:25:03 +0000 Subject: [PATCH] * lib/cmath.rb (CMath.log): second argument: b can be nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/cmath.rb | 2 +- test/test_cmath.rb | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) 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 + + * lib/cmath.rb (CMath.log): second argument: b can be nil. + Thu Jun 30 06:23:28 2011 Eric Hodel * 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