block tests for if and while
bundle update too
This commit is contained in:
34
test/risc/interpreter/blocks/test_if.rb
Normal file
34
test/risc/interpreter/blocks/test_if.rb
Normal file
@ -0,0 +1,34 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Risc
|
||||
module BlockIfOp
|
||||
include Ticker
|
||||
def setup
|
||||
@string_input = block_main("a = tenner {|b| if( b #{op} 5 ); return 1;else;return 2;end } ; return a" , tenner)
|
||||
super
|
||||
end
|
||||
def test_chain
|
||||
#show_main_ticks # get output of what is
|
||||
run_all
|
||||
assert_equal res , get_return , "10 #{op} 5"
|
||||
end
|
||||
end
|
||||
class BlockIfSmall < MiniTest::Test
|
||||
include BlockIfOp
|
||||
def op
|
||||
"<"
|
||||
end
|
||||
def res
|
||||
2
|
||||
end
|
||||
end
|
||||
class BlockIfLarge < MiniTest::Test
|
||||
include BlockIfOp
|
||||
def op
|
||||
">"
|
||||
end
|
||||
def res
|
||||
1
|
||||
end
|
||||
end
|
||||
end
|
19
test/risc/interpreter/blocks/test_while.rb
Normal file
19
test/risc/interpreter/blocks/test_while.rb
Normal file
@ -0,0 +1,19 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Risc
|
||||
class BlockWhile < MiniTest::Test
|
||||
include Ticker
|
||||
def setup
|
||||
@string_input = block_main("a = tenner {|b| #{while_str} } ; return a" , tenner)
|
||||
super
|
||||
end
|
||||
def while_str
|
||||
"while( b > 5); b = b - 1 ;end;return b"
|
||||
end
|
||||
def test_chain
|
||||
#show_main_ticks # get output of what is
|
||||
run_all
|
||||
assert_equal 5 , get_return , while_str
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user