fixes all but interpreter tests

This commit is contained in:
Torsten Ruger
2018-04-06 23:37:41 +03:00
parent eea92399ee
commit 3c90eb31c6
9 changed files with 111 additions and 105 deletions

View File

@ -7,12 +7,11 @@ module Risc
def setup
super
@input = "5.mod4"
@expect = [LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, SlotToReg, LoadConstant, FunctionCall,
Label]
@expect = [LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label]
end
def test_send_instructions
@ -20,24 +19,24 @@ module Risc
end
def test_load_5
produced = produce_body
assert_equal 5 , produced.next(16).constant.value
assert_equal 5 , produced.next(15).constant.value
end
def test_load_label
produced = produce_body
assert_equal Label , produced.next(19).constant.class
assert_equal Label , produced.next(18).constant.class
end
def test_call_reg_setup
produced = produce_body
assert_equal produced.next(23).register , produced.next(24).register
assert_equal produced.next(22).register , produced.next(23).register
end
def test_function_call
produced = produce_body
assert_equal FunctionCall , produced.next(24).class
assert_equal :mod4 , produced.next(24).method.name
assert_equal FunctionCall , produced.next(23).class
assert_equal :mod4 , produced.next(23).method.name
end
def test_check_continue
produced = produce_body
assert produced.next(25).name.start_with?("continue_")
assert produced.next(24).name.start_with?("continue_")
end
#TODO check the message setup, type and frame moves
end