aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-15 13:21:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-15 13:21:38 +0000
commite7d29c6cdadbb08d39219a05d795fe6c38414e19 (patch)
tree158ca07b9a2bbe70ec90d308329f9cbd13fd55c7 /test
parentca5739979dc932e809cb70d243ecc07d380d2725 (diff)
downloadruby-e7d29c6cdadbb08d39219a05d795fe6c38414e19.tar.gz
hash.c: iteration level with reentering
* hash.c (hash_foreach_iter, hash_foreach_ensure, rb_hash_foreach): deal with iteration level when reentering by callcc. temporary measure until rollback of ensure is introduced. [ruby-dev:47807] [Bug #9105] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_hash.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index e998c52621..4da8e234de 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -930,7 +930,9 @@ class TestHash < Test::Unit::TestCase
h.clear
c.call
end
+ end
+ def test_callcc_iter_level
bug9105 = '[ruby-dev:47803] [Bug #9105]'
h = @cls[1=>2, 3=>4]
c = nil
@@ -948,6 +950,22 @@ class TestHash < Test::Unit::TestCase
end
end
+ def test_threaded_iter_level
+ bug9105 = '[ruby-dev:47807] [Bug #9105]'
+ h = @cls[1=>2]
+ 2.times.map {
+ f = false
+ th = Thread.start {h.each {f = true; sleep}}
+ Thread.pass until f
+ Thread.pass until th.stop?
+ th
+ }.each {|th| th.run; th.join}
+ assert_nothing_raised(RuntimeError, bug9105) do
+ h[5] = 6
+ end
+ assert_equal(6, h[5], bug9105)
+ end
+
def test_compare_by_identity
a = "foo"
assert_not_predicate(@cls[], :compare_by_identity?)