summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-04 13:14:25 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-04 13:14:25 +0000
commita821725ab0df0cbec2a8644498644c9f826d49c8 (patch)
treef304c87af3ba1d3114c96df77cab48bf6e3aea0c /test/ruby
parentd681d98052c9fd5060dc5fe6f1462bb27db533c1 (diff)
* test/ruby/test_complex.rb: added some tests.
* test/ruby/test_rational.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_complex.rb29
-rw-r--r--test/ruby/test_rational.rb14
2 files changed, 42 insertions, 1 deletions
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index 5d4916e1d0..d5a8a18524 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
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 5758749d5e..703d56a2ab 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -129,6 +129,13 @@ class Rational_Test < Test::Unit::TestCase
assert_raise(ArgumentError){Rational(Object.new)}
assert_raise(ArgumentError){Rational()}
assert_raise(ArgumentError){Rational(1,2,3)}
+
+ if (0.0/0).nan?
+ assert_raise(FloatDomainError){Rational(0.0/0)}
+ end
+ if (1.0/0).infinite?
+ assert_raise(FloatDomainError){Rational(1.0/0)}
+ end
end
def test_attr
@@ -935,6 +942,13 @@ class Rational_Test < Test::Unit::TestCase
assert_raise(RangeError){Complex(1,2).to_r}
end
end
+
+ if (0.0/0).nan?
+ assert_raise(FloatDomainError){(0.0/0).to_r}
+ end
+ if (1.0/0).infinite?
+ assert_raise(FloatDomainError){(1.0/0).to_r}
+ end
end
def test_gcdlcm