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