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:
parent
cac44def0b
commit
5f95edb7af
1 changed files with 10 additions and 6 deletions
|
@ -1729,20 +1729,24 @@ class TestHash < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_huge_iter_level
|
def test_huge_iter_level
|
||||||
h = @cls[a: 1]
|
nrec = 200
|
||||||
assert_raise(RuntimeError){
|
|
||||||
hrec(h, 1000){ h[:c] = 3 }
|
|
||||||
}
|
|
||||||
|
|
||||||
h = @cls[a: 1]
|
h = @cls[a: 1]
|
||||||
hrec(h, 1000){}
|
hrec(h, nrec){}
|
||||||
h[:c] = 3
|
h[:c] = 3
|
||||||
assert_equal(3, h[:c])
|
assert_equal(3, h[:c])
|
||||||
|
|
||||||
h = @cls[a: 1]
|
h = @cls[a: 1]
|
||||||
h.freeze # set hidden attribute for a frozen object
|
h.freeze # set hidden attribute for a frozen object
|
||||||
hrec(h, 1000){}
|
hrec(h, nrec){}
|
||||||
assert_equal(1, h.size)
|
assert_equal(1, h.size)
|
||||||
|
|
||||||
|
h = @cls[a: 1]
|
||||||
|
assert_raise(RuntimeError){
|
||||||
|
hrec(h, nrec){ h[:c] = 3 }
|
||||||
|
}
|
||||||
|
rescue SystemStackError => e
|
||||||
|
# ignore
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestSubHash < TestHash
|
class TestSubHash < TestHash
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue