2018-04-23 13:16:46 +03:00
|
|
|
require_relative "../helper"
|
2018-03-24 12:21:46 +02:00
|
|
|
|
|
|
|
module Risc
|
2018-04-01 14:01:17 +03:00
|
|
|
class InterpreterDiv10 < MiniTest::Test
|
2018-03-24 12:21:46 +02:00
|
|
|
include Ticker
|
|
|
|
|
|
|
|
def setup
|
2018-04-01 14:50:13 +03:00
|
|
|
@string_input = as_main("return 25.div10")
|
2018-03-24 12:21:46 +02:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_chain
|
2019-08-16 21:43:54 +03:00
|
|
|
# show_main_ticks # get output of what is
|
2019-08-22 12:26:40 +03:00
|
|
|
check_main_chain [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
2018-08-12 15:02:23 +03:00
|
|
|
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, # 10
|
2019-08-22 12:26:40 +03:00
|
|
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
|
|
|
|
FunctionCall, LoadConstant, SlotToReg, LoadConstant, OperatorInstruction, # 20
|
|
|
|
IsNotZero, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
|
|
|
Transfer, Transfer, Branch, LoadData, OperatorInstruction, # 30
|
|
|
|
LoadData, OperatorInstruction, OperatorInstruction, LoadData, Transfer,
|
|
|
|
OperatorInstruction, OperatorInstruction, LoadData, Transfer, OperatorInstruction, # 40
|
|
|
|
OperatorInstruction, LoadData, Transfer, OperatorInstruction, OperatorInstruction,
|
|
|
|
LoadData, OperatorInstruction, LoadData, Transfer, OperatorInstruction, # 50
|
|
|
|
OperatorInstruction, Transfer, LoadData, OperatorInstruction, LoadData,
|
|
|
|
OperatorInstruction, OperatorInstruction, Branch, RegToSlot, RegToSlot, # 60
|
|
|
|
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
|
|
|
|
RegToSlot, RegToSlot, SlotToReg, SlotToReg, SlotToReg, # 70
|
|
|
|
FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg,
|
|
|
|
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, # 80
|
|
|
|
RegToSlot, SlotToReg, SlotToReg, SlotToReg, Branch,
|
|
|
|
FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, # 90
|
|
|
|
NilClass, ]
|
2018-06-19 18:55:47 +03:00
|
|
|
assert_equal 2 , get_return
|
2018-03-24 12:21:46 +02:00
|
|
|
end
|
|
|
|
|
2018-04-01 14:50:13 +03:00
|
|
|
def test_load_25
|
2018-08-12 15:02:23 +03:00
|
|
|
load_ins = main_ticks 9
|
2018-03-24 12:21:46 +02:00
|
|
|
assert_equal LoadConstant , load_ins.class
|
2018-04-01 14:50:13 +03:00
|
|
|
assert_equal 25 , @interpreter.get_register(load_ins.register).value
|
2018-03-24 12:21:46 +02:00
|
|
|
end
|
2018-11-24 22:40:22 +02:00
|
|
|
def test_load_space
|
2019-08-22 12:26:40 +03:00
|
|
|
load_ins = main_ticks 64
|
2018-11-24 22:40:22 +02:00
|
|
|
assert_load load_ins, Parfait::Factory
|
|
|
|
end
|
2018-05-30 12:54:40 +03:00
|
|
|
def test_return_class
|
2019-08-22 12:26:40 +03:00
|
|
|
ret = main_ticks(86)
|
2018-03-24 12:21:46 +02:00
|
|
|
assert_equal FunctionReturn , ret.class
|
|
|
|
link = @interpreter.get_register( ret.register )
|
2019-02-07 18:24:35 +02:00
|
|
|
assert_equal ::Integer , link.class
|
2018-03-24 12:21:46 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|