diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-03 13:32:24 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-03 13:32:24 +0000 |
commit | 218d1f5e1e2377b237c294e871bd3bfd6abf6633 (patch) | |
tree | 5d10d6718b479a1f3ad9eab92365881b3415a5fd /test/ruby/test_thread.rb | |
parent | 6f2efe84fb6169a03ed191606935a40640d6764c (diff) | |
download | ruby-218d1f5e1e2377b237c294e871bd3bfd6abf6633.tar.gz |
hash.c: same hash value for similar constructs
* hash.c (rb_hash_recursive): make similar (recursive) constructs
return same hash value. execute recursively, and rewind to the
topmost frame with an object which .eql? to the recursive
object, if recursion is detected.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_thread.rb')
-rw-r--r-- | test/ruby/test_thread.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index f74c4ec9cb..ab1b81a8fe 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -467,6 +467,19 @@ class TestThread < Test::Unit::TestCase m.unlock end + def test_recursive_outer + arr = [] + obj = Struct.new(:foo, :visited).new(arr, false) + arr << obj + def obj.hash + self[:visited] = true + super + raise "recursive_outer should short circuit intermediate calls" + end + assert_nothing_raised {arr.hash} + assert(obj[:visited], "obj.hash was not called") + end + def test_thread_instance_variable bug4389 = '[ruby-core:35192]' assert_in_out_err([], <<-INPUT, %w(), [], bug4389) |