summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_zjit.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb
index e347986abc..2066610cb2 100644
--- a/test/ruby/test_zjit.rb
+++ b/test/ruby/test_zjit.rb
@@ -470,6 +470,42 @@ class TestZJIT < Test::Unit::TestCase
}, insns: [:getblockparamproxy]
end
+ def test_getblockparam
+ assert_compiles '2', %q{
+ def test(&blk)
+ blk
+ end
+ test { 2 }.call
+ test { 2 }.call
+ }, insns: [:getblockparam]
+ end
+
+ def test_getblockparam_proxy_side_exit_restores_block_local
+ assert_compiles '2', %q{
+ def test(&block)
+ b = block
+ # sideexits here
+ raise "test" unless block
+ b ? 2 : 3
+ end
+ test {}
+ test {}
+ }, insns: [:getblockparam, :getblockparamproxy]
+ end
+
+ def test_getblockparam_used_twice_in_args
+ assert_compiles '1', %q{
+ def f(*args) = args
+ def test(&blk)
+ b = blk
+ f(*[1], blk)
+ blk
+ end
+ test {1}.call
+ test {1}.call
+ }, insns: [:getblockparam]
+ end
+
def test_optimized_method_call_proc_call
assert_compiles '2', %q{
p = proc { |x| x * 2 }