diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_complex.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index ef612e2279..6f9cabb7b9 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) |