fixing most of the risc tests

This commit is contained in:
2019-08-23 15:31:22 +03:00
parent 50c172915e
commit 4ca16e5f9a
21 changed files with 265 additions and 293 deletions

View File

@ -11,19 +11,16 @@ module Risc
def test_mult
#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, LoadConstant,
SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, # 20
SlotToReg, LoadConstant, OperatorInstruction, IsNotZero, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, # 30
Branch, OperatorInstruction, RegToSlot, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, # 40
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn,
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, # 50
RegToSlot, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
Branch, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, # 60
Transfer, SlotToReg, SlotToReg, Syscall, NilClass, ]
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #10
RegToSlot, SlotToReg, FunctionCall, LoadConstant, SlotToReg, #15
LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, RegToSlot, #20
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, #25
RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, #30
Branch, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #35
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #40
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #45
Transfer, SlotToReg, SlotToReg, Syscall, NilClass,] #50
assert_equal 0 , get_return
end
def test_zero
@ -31,7 +28,7 @@ module Risc
assert @interpreter.flags[:zero]
end
def test_op
op = main_ticks(32)
op = main_ticks(25)
assert_equal OperatorInstruction , op.class
assert_equal :r2 , op.left.symbol
assert_equal :r3 , op.right.symbol
@ -39,7 +36,7 @@ module Risc
assert_equal 2**31 , @interpreter.get_register(:r3)
end
def test_overflow
main_ticks( 36 )
main_ticks( 26 )
assert @interpreter.flags[:overflow]
end
end