fix most of mom from calling changes

This commit is contained in:
2019-08-22 22:56:44 +03:00
parent 0c49612e5e
commit 017e7e2971
17 changed files with 106 additions and 84 deletions

View File

@ -7,11 +7,10 @@ module Risc
def setup
super
@input = "if(@a) ; arg = 5 ; else; arg = 6; end;return"
@expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero,
LoadConstant, OperatorInstruction, IsZero, Label, LoadConstant,
SlotToReg, RegToSlot, Branch, Label, LoadConstant,
SlotToReg, RegToSlot, Label, LoadConstant, #34
RegToSlot, Branch]
@expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero, #4
LoadConstant, OperatorInstruction, IsZero, Label, LoadConstant, #9
RegToSlot, Branch, Label, LoadConstant, RegToSlot, #14
Label, LoadConstant, RegToSlot, Branch] #19
end
def test_if_instructions
@ -24,7 +23,9 @@ module Risc
end
def test_false_check
produced = produce_body
assert_equal produced.next(13) , produced.next(4).label
assert_equal IsZero , produced.next(7).class
assert_equal Label , produced.next(12).class
assert_equal produced.next(12).name , produced.next(7).label.name
end
def test_nil_load
produced = produce_body
@ -32,22 +33,27 @@ module Risc
end
def test_nil_check
produced = produce_body
assert_equal produced.next(13) , produced.next(7).label
assert_equal IsZero , produced.next(4).class
assert_equal Label , produced.next(12).class
assert_equal produced.next(12).name , produced.next(4).label.name
end
def test_true_label
produced = produce_body
assert_equal Label , produced.next(8).class
assert produced.next(8).name.start_with?("true_label")
end
def test_merge_label
produced = produce_body
assert produced.next(17).name.start_with?("merge_label")
assert_equal Label , produced.next(15).class
assert produced.next(15).name.start_with?("merge_label")
end
def test_true_jump # should jumpp to merge label
produced = produce_body
assert produced.next(12).label.name.start_with?("merge_label")
assert_equal Branch , produced.next(11).class
assert produced.next(11).label.name.start_with?("merge_label")
end
end
end