rubyx/test/risc/interpreter/calling/test_mod.rb

41 lines
1.5 KiB
Ruby
Raw Normal View History

2018-04-23 12:16:46 +02:00
require_relative "../helper"
2015-08-04 21:01:20 +02:00
module Risc
class InterpreterMod < MiniTest::Test
2017-01-03 21:42:40 +01:00
include Ticker
2017-01-03 21:42:40 +01:00
def setup
2018-04-19 09:00:55 +02:00
@string_input = as_main "return 9.div4"
2017-01-03 21:42:40 +01:00
super
end
2015-10-16 16:13:08 +02:00
def test_chain
# show_main_ticks # get output of what is
check_main_chain [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, # 10
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, LoadConstant, SlotToReg, LoadConstant, OperatorInstruction, # 20
IsNotZero, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
LoadData, OperatorInstruction, Branch, RegToSlot, RegToSlot, # 30
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, RegToSlot, SlotToReg, SlotToReg, SlotToReg, # 40
FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, # 50
RegToSlot, SlotToReg, SlotToReg, SlotToReg, Branch,
FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, # 60
NilClass, ]
assert_equal 2 , get_return
2017-01-03 21:42:40 +01:00
end
2015-08-04 21:01:20 +02:00
def test_op
op = main_ticks(27)
assert_equal OperatorInstruction , op.class
assert_equal :>> , op.operator
assert_equal :r2 , op.left.symbol
assert_equal :r3 , op.right.symbol
assert_equal 2 , @interpreter.get_register(:r2)
assert_equal 2 , @interpreter.get_register(:r3)
2017-01-03 21:42:40 +01:00
end
2015-08-04 21:01:20 +02:00
end
end