summaryrefslogtreecommitdiffstats
path: root/test/ruby/test_complex.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-05 13:33:29 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-05 13:33:29 +0000
commitfd9512af65aea6e8ef4d70c20db9497717940f0c (patch)
treed2e4b31d5386417720d2f73960f96f3edab2650e /test/ruby/test_complex.rb
parent60b5b73dafed17a1e82808f2778a8743fd0c3447 (diff)
downloadruby-fd9512af65aea6e8ef4d70c20db9497717940f0c.tar.gz
ruby-fd9512af65aea6e8ef4d70c20db9497717940f0c.tar.xz
ruby-fd9512af65aea6e8ef4d70c20db9497717940f0c.zip
merges r20514 from trunk into ruby_1_9_1.
* test/ruby/test_complex.rb: added some tests. * test/ruby/test_rational.rb: ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@20548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_complex.rb')
-rw-r--r--test/ruby/test_complex.rb29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index 5d4916e1d..d5a8a1852 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -27,7 +27,7 @@ class Complex_Test < Test::Unit::TestCase
c2 = c - 1
assert_instance_of(ComplexSub, c2)
- c3 = c - c
+ c3 = c - c2
assert_instance_of(ComplexSub, c3)
s = Marshal.dump(c)
@@ -71,6 +71,12 @@ class Complex_Test < Test::Unit::TestCase
h[Complex(0.0,0.0)] = 9.0
assert_equal(5, h.size)
+
+ if (0.0/0).nan? && !((0.0/0).eql?(0.0/0))
+ h = {}
+ 3.times{h[Complex(0.0/0)] = 1}
+ assert_equal(3, h.size)
+ end
end
def test_freeze
@@ -124,6 +130,13 @@ class Complex_Test < Test::Unit::TestCase
assert_raise(ArgumentError){Complex(Object.new)}
assert_raise(ArgumentError){Complex()}
assert_raise(ArgumentError){Complex(1,2,3)}
+
+ if (0.0/0).nan?
+ assert_nothing_raised{Complex(0.0/0)}
+ end
+ if (1.0/0).infinite?
+ assert_nothing_raised{Complex(1.0/0)}
+ end
end
def test_attr
@@ -483,6 +496,13 @@ class Complex_Test < Test::Unit::TestCase
assert_equal(true, Complex(2,1) != Complex(1))
assert_equal(false, Complex(1) == nil)
assert_equal(false, Complex(1) == '')
+
+ nan = 0.0 / 0
+ if nan.nan? && nan != nan
+ assert_equal(false, Complex(nan, 0) == Complex(nan, 0))
+ assert_equal(false, Complex(0, nan) == Complex(0, nan))
+ assert_equal(false, Complex(nan, nan) == Complex(nan, nan))
+ end
end
def test_unify
@@ -822,6 +842,13 @@ class Complex_Test < Test::Unit::TestCase
c = Complex(1,2).to_c
assert_equal([1, 2], [c.real, c.imag])
+
+ if (0.0/0).nan?
+ assert_nothing_raised{(0.0/0).to_c}
+ end
+ if (1.0/0).infinite?
+ assert_nothing_raised{(1.0/0).to_c}
+ end
end
def test_supp