1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* complex.c (f_{add,mul,sub}): omitted some shortcuts for preserve

signed zero anyway.

	* complex.c (nucomp_negate): new.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2008-09-14 01:16:44 +00:00
parent 19416601a0
commit e4b3a81769
4 changed files with 56 additions and 0 deletions

View file

@ -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)