test and last fixes for previous commits (allocalte ints)
mostly just fixing the additional instructions close #20
This commit is contained in:
@ -14,32 +14,28 @@ module Risc
|
||||
check_main_chain [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
||||
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, # 10
|
||||
RegToSlot, LoadConstant, SlotToReg, Branch, RegToSlot,
|
||||
SlotToReg, FunctionCall, SlotToReg, SlotToReg, LoadData, # 20
|
||||
OperatorInstruction, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
||||
RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, # 30
|
||||
Branch, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
|
||||
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, # 40
|
||||
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
|
||||
Branch, SlotToReg, SlotToReg, RegToSlot, Branch, # 50
|
||||
LoadConstant, SlotToReg, RegToSlot, RegToSlot, SlotToReg,
|
||||
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, # 60
|
||||
SlotToReg, Syscall, NilClass, ]
|
||||
SlotToReg, FunctionCall, LoadConstant, SlotToReg, LoadConstant, # 20
|
||||
OperatorInstruction, IsNotZero, SlotToReg, RegToSlot, SlotToReg,
|
||||
Branch, SlotToReg, LoadData, OperatorInstruction, RegToSlot, # 30
|
||||
RegToSlot, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
|
||||
SlotToReg, RegToSlot, RegToSlot, SlotToReg, Branch, # 40
|
||||
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
|
||||
RegToSlot, SlotToReg, SlotToReg, RegToSlot, Branch, # 50
|
||||
SlotToReg, SlotToReg, RegToSlot, Branch, LoadConstant,
|
||||
SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, # 60
|
||||
SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg,
|
||||
Syscall, NilClass, ]
|
||||
assert_equal 2 , get_return
|
||||
end
|
||||
|
||||
def test_load
|
||||
lod = main_ticks(9)
|
||||
assert_equal LoadConstant , lod.class
|
||||
assert_equal 9 , lod.constant.value
|
||||
def test_op
|
||||
op = main_ticks(29)
|
||||
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)
|
||||
end
|
||||
def test_fix # reduce self to fix
|
||||
sl = main_ticks(19)
|
||||
assert_equal SlotToReg , sl.class
|
||||
assert_equal :r1 , sl.array.symbol
|
||||
assert_equal 2 , sl.index
|
||||
assert_equal :r1 , sl.register.symbol
|
||||
assert_equal 9 , @interpreter.get_register(:r1)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user