rubyx/test/risc/interpreter/test_mod.rb

57 lines
2.0 KiB
Ruby
Raw Normal View History

2015-08-04 21:01:20 +02:00
require_relative "helper"
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
@string_input = as_main "return 9.mod4"
2017-01-03 21:42:40 +01:00
super
end
2015-10-16 16:13:08 +02:00
def test_chain
2017-01-03 21:42:40 +01:00
#show_ticks # get output of what is
2018-03-24 17:33:19 +01:00
check_chain [Branch, Label, LoadConstant, SlotToReg, LoadConstant,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, LoadConstant, RegToSlot, LoadConstant, RegToSlot,
FunctionCall, Label, LoadConstant, SlotToReg, SlotToReg,
2018-03-24 17:33:19 +01:00
RegToSlot, LoadConstant, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
LoadConstant, FunctionCall, Label, SlotToReg, SlotToReg,
LoadData, OperatorInstruction, LoadConstant, SlotToReg, SlotToReg,
RegToSlot, RegToSlot, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, FunctionReturn, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
FunctionReturn, Transfer, Syscall, NilClass]
assert_equal Parfait::Integer , get_return.class
assert_equal 2 , get_return.value
2017-01-03 21:42:40 +01:00
end
2015-08-04 21:01:20 +02:00
def test_load
lod = ticks(44)
assert_equal LoadConstant , lod.class
assert_equal 9 , lod.constant.value
2017-01-03 21:42:40 +01:00
end
def test_fix # reduce self to fix
sl = ticks(55)
assert_equal SlotToReg , sl.class
assert_equal :r1 , sl.array.symbol
assert_equal 3 , sl.index
assert_equal :r1 , sl.register.symbol
assert_equal 9 , @interpreter.get_register(:r1)
2017-01-03 21:42:40 +01:00
end
def test_sys
sys = ticks(83)
assert_equal Syscall , sys.class
assert_equal :exit , sys.name
2017-01-03 21:42:40 +01:00
end
2015-08-04 21:01:20 +02:00
end
end