more block tests working

dynamic calls and operators on block args
(giant strides)
This commit is contained in:
Torsten Ruger 2018-08-01 16:31:16 +03:00
parent 4b4528abb2
commit 4f3c0d8b08
3 changed files with 56 additions and 1 deletions

View 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

View 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

View File

@ -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