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

Add a small test for the code GC

This commit is contained in:
Maxime Chevalier-Boisvert 2021-08-31 14:26:18 -04:00 committed by Alan Wu
parent e527912fe0
commit 9d5b3e1d0f

View file

@ -441,6 +441,29 @@ assert_equal '7', %q{
foo(4)[1] foo(4)[1]
} }
# Method redefinition while the method is on the stack
assert_equal '[777, 1]', %q{
def foo
redef()
777
end
def redef
# Redefine the global foo
eval("def foo; 1; end", TOPLEVEL_BINDING)
# Collect dead code
GC.stress = true
GC.start
# But we will return to the original foo,
# which remains alive because it's on the stack
end
# Must produce [777, 1]
[foo, foo]
}
# Test for GC safety. Don't invalidate dead iseqs. # Test for GC safety. Don't invalidate dead iseqs.
assert_normal_exit %q{ assert_normal_exit %q{
Class.new do Class.new do