summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2024-04-17 16:30:47 +0900
committerKoichi Sasada <ko1@atdot.net>2024-04-17 17:03:46 +0900
commitf9f301800199e7b5b9a6e92cf726cd0214d417a4 (patch)
tree0767b9536a638f7e8a961f3f0d54c171c3065cad /test/ruby
parent0b630d644128da611c73fd9fc28d3ee2e9cd80c0 (diff)
`ISeq#to_a` respects `use_block` status
```ruby b = RubyVM::InstructionSequence.compile('def f = yield; def g = nil').to_a pp b #=> ... {:use_block=>true}, ... ```
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_iseq.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index dc84d8bd7c..a31605885a 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -827,6 +827,18 @@ class TestISeq < Test::Unit::TestCase
end
end
+ def block_using_method
+ yield
+ end
+
+ def block_unused_method
+ end
+
+ def test_unused_param
+ assert_equal true, RubyVM::InstructionSequence.of(method(:block_using_method)).to_a.dig(11, :use_block)
+ assert_equal nil, RubyVM::InstructionSequence.of(method(:block_unused_method)).to_a.dig(11, :use_block)
+ end
+
def test_compile_prism_with_invalid_object_type
assert_raise(TypeError) do
RubyVM::InstructionSequence.compile_prism(Object.new)