2018-04-23 18:39:16 +02:00
|
|
|
require_relative "../helper"
|
|
|
|
|
|
|
|
module Risc
|
2018-04-24 18:46:22 +02:00
|
|
|
class InterpreterIfGreater < MiniTest::Test
|
2018-04-23 18:39:16 +02:00
|
|
|
include Ticker
|
|
|
|
|
|
|
|
def setup
|
2018-06-19 17:55:47 +02:00
|
|
|
@string_input = as_main 'if( 5 > 5 ); return 1;else;return 2;end'
|
2018-04-23 18:39:16 +02:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_if
|
|
|
|
#show_main_ticks # get output of what is in main
|
2018-06-19 17:55:47 +02:00
|
|
|
check_main_chain [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
2018-05-24 20:20:56 +02:00
|
|
|
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
2018-07-22 21:29:32 +02:00
|
|
|
RegToSlot, RegToSlot, SlotToReg, Branch, RegToSlot,
|
|
|
|
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
|
|
|
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
|
|
|
|
SlotToReg, FunctionCall, SlotToReg, SlotToReg, SlotToReg,
|
|
|
|
SlotToReg, SlotToReg, OperatorInstruction, IsMinus, IsZero,
|
|
|
|
LoadConstant, RegToSlot, SlotToReg, Branch, SlotToReg,
|
2018-05-30 11:54:40 +02:00
|
|
|
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
|
2018-07-22 21:29:32 +02:00
|
|
|
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
|
|
|
LoadConstant, OperatorInstruction, IsZero, LoadConstant, RegToSlot,
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg,
|
|
|
|
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg,
|
|
|
|
SlotToReg, Branch, Syscall, NilClass]
|
2018-06-19 17:55:47 +02:00
|
|
|
assert_equal 2 , get_return
|
2018-04-23 18:39:16 +02:00
|
|
|
end
|
|
|
|
def test_exit
|
2018-07-22 21:29:32 +02:00
|
|
|
done = main_ticks(68)
|
2018-04-23 18:39:16 +02:00
|
|
|
assert_equal Syscall , done.class
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|