ruby-changes:8978
From: tadf <ko1@a...>
Date: Thu, 4 Dec 2008 22:14:38 +0900 (JST)
Subject: [ruby-changes:8978] Ruby:r20514 (trunk): * test/ruby/test_complex.rb: added some tests.
tadf 2008-12-04 22:14:25 +0900 (Thu, 04 Dec 2008) New Revision: 20514 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20514 Log: * test/ruby/test_complex.rb: added some tests. * test/ruby/test_rational.rb: ditto. Modified files: trunk/ChangeLog trunk/test/ruby/test_complex.rb trunk/test/ruby/test_rational.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 20513) +++ ChangeLog (revision 20514) @@ -1,3 +1,9 @@ +Thu Dec 4 22:13:55 2008 Tadayoshi Funaba <tadf@d...> + + * test/ruby/test_complex.rb: added some tests. + + * test/ruby/test_rational.rb: ditto. + Thu Dec 4 19:56:20 2008 Tanaka Akira <akr@f...> * lib/open3.rb (Open3.popen3): simplified. Index: test/ruby/test_complex.rb =================================================================== --- test/ruby/test_complex.rb (revision 20513) +++ test/ruby/test_complex.rb (revision 20514) @@ -27,7 +27,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 Index: test/ruby/test_rational.rb =================================================================== --- test/ruby/test_rational.rb (revision 20513) +++ test/ruby/test_rational.rb (revision 20514) @@ -129,6 +129,13 @@ 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 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/