From 52220154a8310d0140829daa1de665003bb11dec Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 22 Dec 2017 08:52:11 +0000 Subject: force hash values fixable * include/ruby/ruby.h (RB_ST2FIX): force fixable on LLP64 environment. * hash.c (any_hash): ditto. [ruby-core:84395] [Bug #14218] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_hash.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index ea19ba80a7..4223aa8140 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1596,6 +1596,13 @@ class TestHash < Test::Unit::TestCase assert_equal(%w(1.0 2.1 3.2), y.values_at(:a, :b, :c)) end + def test_broken_hash_value + bug14218 = '[ruby-core:84395] [Bug #14218]' + + assert_equal(0, 1_000_000.times.count{a=Object.new.hash; b=Object.new.hash; a < 0 && b < 0 && a + b > 0}, bug14218) + assert_equal(0, 1_000_000.times.count{a=Object.new.hash; b=Object.new.hash; 0 + a + b != 0 + b + a}, bug14218) + end + class TestSubHash < TestHash class SubHash < Hash def reject(*) -- cgit v1.2.3