From ae1630ba2faaf110999797d60241f8a397e53f4b Mon Sep 17 00:00:00 2001 From: tadf Date: Sun, 14 Sep 2008 01:16:44 +0000 Subject: * 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 --- test/ruby/test_complex.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/ruby') 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) -- cgit