Fixing tests for implicit return

previous commit affected rather many test, as the implicit returns add extra instructions
Also added some explicit returns, so as not to test the return logic too much. return (ie return nl) is a knonwn 3 risc operation.
This commit is contained in:
2019-08-17 23:29:42 +03:00
parent 32f908c127
commit 5a43cbff15
43 changed files with 152 additions and 107 deletions

View File

@ -18,7 +18,7 @@ module Risc
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, #44
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, #49
LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, #54
SlotToReg, DynamicJump, Label]
SlotToReg, DynamicJump, Label, SlotToReg, RegToSlot, Branch]
end
def test_send_instructions

View File

@ -10,7 +10,7 @@ module Risc
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label]
FunctionCall, Label, SlotToReg, RegToSlot, Branch]
end
def test_send_instructions

View File

@ -11,7 +11,7 @@ module Risc
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall,
Label]
Label, SlotToReg, RegToSlot, Branch]
end
def test_send_instructions

View File

@ -6,11 +6,11 @@ module Risc
def setup
super
@input = "5.div4"
@input = "return 5.div4"
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label]
FunctionCall, Label, SlotToReg, RegToSlot, Branch]
@produced = produce_body
end
@ -51,7 +51,7 @@ module Risc
assert_reg_to_slot( sl , :r1 , :r3 , 7 )
end
def test_label
sl = @produced.next( 17 )
sl = @produced.next( 20 )
assert_equal Risc::Label , sl.class
assert_equal "return_label" , sl.name
end