Skip to content

Commit a3c0955

Browse files
committed
Test roundtripping iseq to binary with anonymous ID
1 parent 47b6894 commit a3c0955

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

test/ruby/test_iseq.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,13 +861,21 @@ def test_unreachable_next_in_block
861861

862862
def test_serialize_anonymous_outer_variables
863863
iseq = RubyVM::InstructionSequence.compile(<<~'RUBY')
864-
[1].each do
865-
rescue => e
866-
puts it
864+
object = Object.new
865+
def object.test
866+
[1].each do
867+
raise
868+
rescue
869+
return it
870+
end
867871
end
872+
object
868873
RUBY
869874

870-
iseq.to_binary # [Bug # 21370]
875+
binary_iseq = iseq.to_binary # [Bug # 21370]
876+
roundtrip_iseq = RubyVM::InstructionSequence.load_from_binary(binary_iseq)
877+
object = roundtrip_iseq.eval
878+
assert_equal 1, object.test
871879
end
872880

873881
def test_loading_kwargs_memory_leak

0 commit comments

Comments
 (0)