2018-04-23 13:16:46 +03:00
|
|
|
require_relative "../helper"
|
2015-08-04 22:01:20 +03:00
|
|
|
|
2017-01-19 09:02:29 +02:00
|
|
|
module Risc
|
2018-03-31 12:38:30 +03:00
|
|
|
class InterpreterMod < MiniTest::Test
|
2017-01-03 22:42:40 +02:00
|
|
|
include Ticker
|
2015-10-06 00:27:13 +03:00
|
|
|
|
2017-01-03 22:42:40 +02:00
|
|
|
def setup
|
2019-09-13 14:07:12 +03:00
|
|
|
@preload = "Integer.div4"
|
2018-04-19 10:00:55 +03:00
|
|
|
@string_input = as_main "return 9.div4"
|
2017-01-03 22:42:40 +02:00
|
|
|
super
|
|
|
|
end
|
2015-10-16 17:13:08 +03:00
|
|
|
|
2018-03-22 18:54:40 +02:00
|
|
|
def test_chain
|
2019-08-23 15:31:22 +03:00
|
|
|
#show_main_ticks # get output of what is
|
2019-09-13 14:07:12 +03:00
|
|
|
check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
|
2019-08-23 19:25:02 +03:00
|
|
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #10
|
2020-03-15 15:15:07 +02:00
|
|
|
FunctionCall, LoadConstant, LoadConstant, SlotToReg, OperatorInstruction, #15
|
2019-08-23 19:25:02 +03:00
|
|
|
IsNotZero, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #20
|
|
|
|
LoadData, OperatorInstruction, RegToSlot, RegToSlot, SlotToReg, #25
|
2020-03-15 15:15:07 +02:00
|
|
|
RegToSlot, Branch, SlotToReg, Branch, SlotToReg, #30
|
|
|
|
RegToSlot, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, #35
|
2019-09-13 14:07:12 +03:00
|
|
|
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, #40
|
2020-03-15 15:15:07 +02:00
|
|
|
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, #45
|
|
|
|
SlotToReg, Transfer, Syscall, NilClass,] #50
|
2018-06-19 18:55:47 +03:00
|
|
|
assert_equal 2 , get_return
|
2017-01-03 22:42:40 +02:00
|
|
|
end
|
2015-08-04 22:01:20 +03:00
|
|
|
|
2018-11-24 22:40:22 +02:00
|
|
|
def test_op
|
2020-03-15 15:15:07 +02:00
|
|
|
assert_operator 22 , :>>, "message.receiver.data_1" , "integer_1" , "op_>>_"
|
|
|
|
assert_equal 2 , @interpreter.get_register(:integer_1)
|
|
|
|
assert_equal 9 , @interpreter.get_register(:"message.receiver.data_1")
|
2017-01-03 22:42:40 +02:00
|
|
|
end
|
2015-08-04 22:01:20 +03:00
|
|
|
end
|
|
|
|
end
|