Skip to content

Commit

Permalink
split method_with_block.rb into individual files that can be filechec…
Browse files Browse the repository at this point in the history
…ked (#420)
  • Loading branch information
froydnj committed May 11, 2021
1 parent 9ab9ea1 commit abbf92e
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 1,148 deletions.
26 changes: 26 additions & 0 deletions test/testdata/compiler/block-optimizations/block_param_call.rb
@@ -0,0 +1,26 @@
# frozen_string_literal: true
# typed: true
# compiled: true
# run_filecheck: INITIAL
# run_filecheck: OPT

def baz(&blk)
blk.call("baz")
end

# INITIAL-LABEL: "func_Object#baz"
# INITIAL: call i64 @sorbet_getMethodBlockAsProc
# INITIAL: call i64 @sorbet_callBlock
# INITIAL{LITERAL}: }

# OPT-LABEL: "func_Object#baz"
# OPT-NOT: call i64 @sorbet_getMethodBlockAsProc
# OPT-NOT: call i64 @rb_block_proc
# OPT: call i64 @rb_yield_values_kw
# OPT-NOT: call i64 @sorbet_getMethodBlockAsProc
# OPT-NOT: call i64 @rb_block_proc
# OPT{LITERAL}: }

baz do |s|
p s
end
@@ -0,0 +1,32 @@
# frozen_string_literal: true
# typed: true
# compiled: true
# run_filecheck: INITIAL
# run_filecheck: OPT

def foo
yield
end

def bar(&blk)
foo(&blk)
end

# INITIAL-LABEL: "func_Object#bar"
# INITIAL: call i64 @sorbet_getMethodBlockAsProc
# INITIAL: @sorbet_getPassedBlockHandler
# INITIAL: call i64 @sorbet_callFuncWithCache
# INITIAL{LITERAL}: }

# OPT-LABEL: "func_Object#bar"
# OPT-NOT: call i64 @sorbet_getMethodBlockAsProc
# OPT-NOT: call i64 @rb_block_proc
# OPT: @sorbet_getPassedBlockHandler
# OPT: call i64 @sorbet_callFuncWithCache
# OPT-NOT: call i64 @sorbet_getMethodBlockAsProc
# OPT-NOT: call i64 @rb_block_proc
# OPT{LITERAL}: }

bar do
puts "bar"
end
27 changes: 27 additions & 0 deletions test/testdata/compiler/block-optimizations/yield_block_param.rb
@@ -0,0 +1,27 @@
# frozen_string_literal: true
# typed: true
# compiled: true
# run_filecheck: INITIAL
# run_filecheck: OPT

def boo(&blk)
yield
end

# INITIAL-LABEL: "func_Object#boo"
# INITIAL: call i64 @sorbet_getMethodBlockAsProc
# INITIAL: call i64 @sorbet_callBlock
# INITIAL{LITERAL}: }

# OPT-LABEL: "func_Object#boo"
# OPT-NOT: call i64 @sorbet_getMethodBlockAsProc
# OPT-NOT: call i64 @rb_block_proc
# OPT: call i64 @rb_yield_values_kw
# OPT-NOT: call i64 @sorbet_getMethodBlockAsProc
# OPT-NOT: call i64 @rb_block_proc
# OPT{LITERAL}: }

boo do
puts "boohey"
end

27 changes: 27 additions & 0 deletions test/testdata/compiler/block-optimizations/yield_noparams.rb
@@ -0,0 +1,27 @@
# frozen_string_literal: true
# typed: true
# compiled: true
# run_filecheck: INITIAL
# run_filecheck: OPT

def foo
yield
end

# INITIAL-LABEL: "func_Object#foo"
# INITIAL: call i64 @sorbet_getMethodBlockAsProc
# INITIAL: call i64 @sorbet_callBlock
# INITIAL{LITERAL}: }

# OPT-LABEL: "func_Object#foo"
# OPT-NOT: call i64 @sorbet_getMethodBlockAsProc
# OPT-NOT: call i64 @rb_block_proc
# OPT: call i64 @rb_yield_values_kw
# OPT-NOT: call i64 @sorbet_getMethodBlockAsProc
# OPT-NOT: call i64 @rb_block_proc
# OPT{LITERAL}: }

foo do
puts "heey"
end

0 comments on commit abbf92e

Please sign in to comment.