1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

check SystemStackError

This recursive iteration test can cause SystemStackError so
check it correctly.
This commit is contained in:
Koichi Sasada 2019-07-31 15:10:16 +09:00
parent cac44def0b
commit 5f95edb7af

View file

@ -1729,20 +1729,24 @@ class TestHash < Test::Unit::TestCase
end
def test_huge_iter_level
h = @cls[a: 1]
assert_raise(RuntimeError){
hrec(h, 1000){ h[:c] = 3 }
}
nrec = 200
h = @cls[a: 1]
hrec(h, 1000){}
hrec(h, nrec){}
h[:c] = 3
assert_equal(3, h[:c])
h = @cls[a: 1]
h.freeze # set hidden attribute for a frozen object
hrec(h, 1000){}
hrec(h, nrec){}
assert_equal(1, h.size)
h = @cls[a: 1]
assert_raise(RuntimeError){
hrec(h, nrec){ h[:c] = 3 }
}
rescue SystemStackError => e
# ignore
end
class TestSubHash < TestHash