[前][次][番号順一覧][スレッド一覧]

ruby-changes:9012

From: yugui <ko1@a...>
Date: Fri, 5 Dec 2008 22:35:00 +0900 (JST)
Subject: [ruby-changes:9012] Ruby:r20548 (ruby_1_9_1): merges r20514 from trunk into ruby_1_9_1.

yugui	2008-12-05 22:33:29 +0900 (Fri, 05 Dec 2008)

  New Revision: 20548

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20548

  Log:
    merges r20514 from trunk into ruby_1_9_1.
    * test/ruby/test_complex.rb: added some tests.
    * test/ruby/test_rational.rb: ditto.

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/test/ruby/test_complex.rb
    branches/ruby_1_9_1/test/ruby/test_rational.rb

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 20547)
+++ ruby_1_9_1/ChangeLog	(revision 20548)
@@ -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.
+
 Fri Dec  5 18:13:56 2008  NAKAMURA Usaku  <usa@r...>
 
 	* win32/win32.c (rb_w32_read, rb_w32_write, rb_w32_isatty): check
Index: ruby_1_9_1/test/ruby/test_complex.rb
===================================================================
--- ruby_1_9_1/test/ruby/test_complex.rb	(revision 20547)
+++ ruby_1_9_1/test/ruby/test_complex.rb	(revision 20548)
@@ -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: ruby_1_9_1/test/ruby/test_rational.rb
===================================================================
--- ruby_1_9_1/test/ruby/test_rational.rb	(revision 20547)
+++ ruby_1_9_1/test/ruby/test_rational.rb	(revision 20548)
@@ -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/

[前][次][番号順一覧][スレッド一覧]