summaryrefslogtreecommitdiffstats
path: root/test/ruby/test_complex.rb
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-14 01:16:44 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-14 01:16:44 +0000
commitae1630ba2faaf110999797d60241f8a397e53f4b (patch)
tree5809e4e36f761a07aab1fe7252840f8b625d153c /test/ruby/test_complex.rb
parent5bc0e4b0229344e7b2611ebb40bd094f93277530 (diff)
downloadruby-ae1630ba2faaf110999797d60241f8a397e53f4b.tar.gz
ruby-ae1630ba2faaf110999797d60241f8a397e53f4b.tar.xz
ruby-ae1630ba2faaf110999797d60241f8a397e53f4b.zip
* complex.c (f_{add,mul,sub}): omitted some shortcuts for preserve
signed zero anyway. * complex.c (nucomp_negate): new. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_complex.rb')
-rw-r--r--test/ruby/test_complex.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index ef612e227..6f9cabb7b 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -303,6 +303,16 @@ class Complex_Test < Test::Unit::TestCase
assert_equal(Complex(-1,1), +Complex(-1,1))
assert_equal(Complex(1,-1), +Complex(1,-1))
assert_equal(Complex(-1,-1), +Complex(-1,-1))
+
+ if -0.0.to_s == '-0.0'
+ c = +Complex(0.0,0.0)
+ assert_equal('0.0', c.real.to_s)
+ assert_equal('0.0', c.image.to_s)
+
+ c = +Complex(-0.0,-0.0)
+ assert_equal('-0.0', c.real.to_s)
+ assert_equal('-0.0', c.image.to_s)
+ end
end
def test_negate
@@ -313,6 +323,16 @@ class Complex_Test < Test::Unit::TestCase
assert_equal(Complex(-1,1), -Complex(1,-1))
assert_equal(Complex(1,1), -Complex(-1,-1))
+ if -0.0.to_s == '-0.0'
+ c = -Complex(0.0,0.0)
+ assert_equal('-0.0', c.real.to_s)
+ assert_equal('-0.0', c.image.to_s)
+
+ c = -Complex(-0.0,-0.0)
+ assert_equal('0.0', c.real.to_s)
+ assert_equal('0.0', c.image.to_s)
+ end
+
=begin
assert_equal(0, Complex(0).negate)
assert_equal(-2, Complex(2).negate)