2018-04-01 21:42:27 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Risc
|
2018-04-04 19:05:09 +02:00
|
|
|
class InterpreterSimpleIf10 < MiniTest::Test
|
2018-04-01 21:42:27 +02:00
|
|
|
include Ticker
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@string_input = as_main 'if( 10 ); return "then";else;return "else";end'
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_if
|
2018-04-04 19:05:09 +02:00
|
|
|
#show_main_ticks # get output of what is in main
|
|
|
|
check_main_chain [Label, LoadConstant, LoadConstant, OperatorInstruction, IsNotZero,
|
|
|
|
Label, LoadConstant, RegToSlot, SlotToReg, SlotToReg,
|
|
|
|
RegToSlot, SlotToReg, SlotToReg, FunctionReturn, Transfer,
|
|
|
|
Syscall, NilClass]
|
2018-04-01 21:42:27 +02:00
|
|
|
assert_equal Parfait::Word , get_return.class
|
|
|
|
assert_equal "else" , get_return.to_string
|
|
|
|
end
|
|
|
|
def test_exit
|
2018-04-04 19:05:09 +02:00
|
|
|
done = main_ticks(16)
|
2018-04-01 21:42:27 +02:00
|
|
|
assert_equal Syscall , done.class
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|