more block tests working
dynamic calls and operators on block args (giant strides)
This commit is contained in:
parent
4b4528abb2
commit
4f3c0d8b08
26
test/risc/interpreter/blocks/test_call_simple_args.rb
Normal file
26
test/risc/interpreter/blocks/test_call_simple_args.rb
Normal file
@ -0,0 +1,26 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Risc
|
||||
class BlockCallSimpleWithArg < MiniTest::Test
|
||||
include Ticker
|
||||
def setup
|
||||
@string_input = block_main("a = tenner {|b| return b} ; return a" , tenner)
|
||||
super
|
||||
end
|
||||
def test_chain
|
||||
run_all
|
||||
assert_equal 10 , get_return
|
||||
end
|
||||
end
|
||||
class BlockCallArgOp < MiniTest::Test
|
||||
include Ticker
|
||||
def setup
|
||||
@string_input = block_main("a = tenner {|b| return 2 * b} ; return a" , tenner)
|
||||
super
|
||||
end
|
||||
def test_chain
|
||||
run_all
|
||||
assert_equal 20 , get_return
|
||||
end
|
||||
end
|
||||
end
|
27
test/risc/interpreter/blocks/test_dyn_call.rb
Normal file
27
test/risc/interpreter/blocks/test_dyn_call.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Risc
|
||||
class BlockCallDyn < MiniTest::Test
|
||||
include Ticker
|
||||
def setup
|
||||
@string_input = block_main("a = tenner {|b| return b.div4} ; return a" , tenner)
|
||||
super
|
||||
end
|
||||
def test_chain
|
||||
#show_main_ticks # get output of what is
|
||||
run_all
|
||||
assert_equal 2 , get_return , "10.div4"
|
||||
end
|
||||
end
|
||||
class BlockCallArgOpDyn < MiniTest::Test
|
||||
include Ticker
|
||||
def setup
|
||||
@string_input = block_main("a = tenner {|b| return b*b} ; return a" , tenner)
|
||||
super
|
||||
end
|
||||
def test_chain
|
||||
run_all
|
||||
assert_equal 100 , get_return , "10*10"
|
||||
end
|
||||
end
|
||||
end
|
@ -16,7 +16,9 @@ module Risc
|
||||
def yielder
|
||||
"def yielder; return yield ; end"
|
||||
end
|
||||
|
||||
def tenner
|
||||
"def tenner; return yield(10) ;end"
|
||||
end
|
||||
def block_main( main , extra = yielder)
|
||||
in_Space("#{extra} ; def main(arg) ; #{main} ; end")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user