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:
@ -6,8 +6,8 @@ module Risc
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "arg = 5"
|
||||
@expect = [LoadConstant, SlotToReg, RegToSlot]
|
||||
@input = "arg = 5;return"
|
||||
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, Branch]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
|
@ -6,8 +6,8 @@ module Risc
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "@ivar = 5"
|
||||
@expect = [LoadConstant, SlotToReg, RegToSlot]
|
||||
@input = "@ivar = 5;return"
|
||||
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, Branch]
|
||||
end
|
||||
|
||||
def test_local_assign_instructions
|
||||
|
@ -6,8 +6,9 @@ module Risc
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "local = arg"
|
||||
@expect = [SlotToReg, SlotToReg, SlotToReg, RegToSlot]
|
||||
@input = "local = arg; return local"
|
||||
@expect = [SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, #4
|
||||
SlotToReg, RegToSlot, Branch] #9
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
|
@ -6,8 +6,8 @@ module Risc
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "r = false"
|
||||
@expect = [LoadConstant,SlotToReg, RegToSlot]
|
||||
@input = "r = false;return"
|
||||
@expect = [LoadConstant,SlotToReg, RegToSlot,LoadConstant, RegToSlot, Branch]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
|
@ -6,8 +6,8 @@ module Risc
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "r = 5"
|
||||
@expect = [LoadConstant,SlotToReg, RegToSlot]
|
||||
@input = "r = 5;return"
|
||||
@expect = [LoadConstant,SlotToReg, RegToSlot, LoadConstant, RegToSlot, Branch]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
|
@ -6,9 +6,9 @@ module Risc
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "@ivar = 5 ; r = @ivar"
|
||||
@input = "@ivar = 5 ; r = @ivar;return"
|
||||
@expect = [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
|
||||
RegToSlot]
|
||||
RegToSlot, LoadConstant, RegToSlot, Branch]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
|
@ -6,11 +6,12 @@ module Risc
|
||||
|
||||
def setup
|
||||
super
|
||||
@input = "r = 5.div4"
|
||||
@input = "r = 5.div4;return"
|
||||
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
|
||||
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
|
||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
|
||||
FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot]
|
||||
FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot,
|
||||
LoadConstant, RegToSlot, Branch]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
|
Reference in New Issue
Block a user