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

ruby-changes:49989

From: nobu <ko1@a...>
Date: Tue, 30 Jan 2018 14:48:32 +0900 (JST)
Subject: [ruby-changes:49989] nobu:r62107 (trunk): force fixable

nobu	2018-01-30 14:48:28 +0900 (Tue, 30 Jan 2018)

  New Revision: 62107

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62107

  Log:
    force fixable
    
    * complex.c (nucomp_hash): force hash values fixable.
      [ruby-core:85224] [Bug #14420]
    
    * rational.c (nurat_hash): ditto.

  Modified files:
    trunk/complex.c
    trunk/rational.c
    trunk/test/ruby/test_complex.rb
    trunk/test/ruby/test_rational.rb
Index: complex.c
===================================================================
--- complex.c	(revision 62106)
+++ complex.c	(revision 62107)
@@ -1253,7 +1253,7 @@ nucomp_hash(VALUE self) https://github.com/ruby/ruby/blob/trunk/complex.c#L1253
     n = rb_hash(dat->imag);
     h[1] = NUM2LONG(n);
     v = rb_memhash(h, sizeof(h));
-    return LONG2FIX(v);
+    return ST2FIX(v);
 }
 
 /* :nodoc: */
Index: test/ruby/test_rational.rb
===================================================================
--- test/ruby/test_rational.rb	(revision 62106)
+++ test/ruby/test_rational.rb	(revision 62107)
@@ -42,7 +42,9 @@ class Rational_Test < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rational.rb#L42
   end
 
   def test_hash
-    assert_kind_of(Integer, Rational(1,2).hash)
+    h = Rational(1,2).hash
+    assert_kind_of(Integer, h)
+    assert_nothing_raised {h.to_s}
 
     h = {}
     h[Rational(0)] = 0
Index: test/ruby/test_complex.rb
===================================================================
--- test/ruby/test_complex.rb	(revision 62106)
+++ test/ruby/test_complex.rb	(revision 62107)
@@ -48,8 +48,12 @@ class Complex_Test < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_complex.rb#L48
   end
 
   def test_hash
-    assert_kind_of(Integer, Complex(1,2).hash)
-    assert_kind_of(Integer, Complex(1.0,2.0).hash)
+    h = Complex(1,2).hash
+    assert_kind_of(Integer, h)
+    assert_nothing_raised {h.to_s}
+    h = Complex(1.0,2.0).hash
+    assert_kind_of(Integer, h)
+    assert_nothing_raised {h.to_s}
 
     h = {}
     h[Complex(0)] = 0
Index: rational.c
===================================================================
--- rational.c	(revision 62106)
+++ rational.c	(revision 62107)
@@ -1783,7 +1783,7 @@ nurat_hash(VALUE self) https://github.com/ruby/ruby/blob/trunk/rational.c#L1783
     n = rb_hash(dat->den);
     h[1] = NUM2LONG(n);
     v = rb_memhash(h, sizeof(h));
-    return LONG2FIX(v);
+    return ST2FIX(v);
 }
 
 static VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

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