ruby-changes:39491
From: nagachika <ko1@a...>
Date: Fri, 14 Aug 2015 15:37:20 +0900 (JST)
Subject: [ruby-changes:39491] nagachika:r51572 (ruby_2_2): merge revision(s) 51423, 51425: [Backport #9381]
nagachika 2015-08-14 15:37:00 +0900 (Fri, 14 Aug 2015) New Revision: 51572 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51572 Log: merge revision(s) 51423,51425: [Backport #9381] test_hash.rb: add assertions * test/ruby/test_hash.rb (test_wrapper_of_special_const): test other special obejcts. [Bug #9381] * hash.c (rb_any_hash): fix Float hash. rb_dbl_hash() returns a Fixnum, but not a long. [Bug #9381] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/hash.c branches/ruby_2_2/test/ruby/test_hash.rb branches/ruby_2_2/version.h Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 51571) +++ ruby_2_2/ChangeLog (revision 51572) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Fri Aug 14 15:24:12 2015 Nobuyoshi Nakada <nobu@r...> + + * hash.c (rb_any_hash): fix Float hash. rb_dbl_hash() returns a + Fixnum, but not a long. [Bug #9381] + Fri Aug 14 15:09:34 2015 Nobuyoshi Nakada <nobu@r...> * ext/json/parser/parser.rl: raise with messages in UTF-8 Index: ruby_2_2/hash.c =================================================================== --- ruby_2_2/hash.c (revision 51571) +++ ruby_2_2/hash.c (revision 51572) @@ -142,7 +142,7 @@ rb_any_hash(VALUE a) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/hash.c#L142 } else if (FLONUM_P(a)) { /* prevent pathological behavior: [Bug #10761] */ - return rb_dbl_hash(rb_float_value(a)); + goto flt; } hnum = rb_objid_hash((st_index_t)a); } @@ -153,7 +153,9 @@ rb_any_hash(VALUE a) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/hash.c#L153 hnum = rb_objid_hash((st_index_t)a); } else if (BUILTIN_TYPE(a) == T_FLOAT) { - return rb_dbl_hash(rb_float_value(a)); + flt: + hval = rb_dbl_hash(rb_float_value(a)); + hnum = FIX2LONG(hval); } else { hval = rb_hash(a); Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 51571) +++ ruby_2_2/version.h (revision 51572) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.3" #define RUBY_RELEASE_DATE "2015-08-14" -#define RUBY_PATCHLEVEL 165 +#define RUBY_PATCHLEVEL 166 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 8 Index: ruby_2_2/test/ruby/test_hash.rb =================================================================== --- ruby_2_2/test/ruby/test_hash.rb (revision 51571) +++ ruby_2_2/test/ruby/test_hash.rb (revision 51572) @@ -1264,8 +1264,14 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_hash.rb#L1264 end end - hash = {5 => bug9381} - assert_equal(bug9381, hash[wrapper.new(5)]) + bad = [ + 5, true, false, nil, + 0.0, 1.72723e-77, + ].select do |x| + hash = {x => bug9381} + hash[wrapper.new(x)] != bug9381 + end + assert_empty(bad, bug9381) end def test_label_syntax Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r51423,51425 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/