remove IsSame branch from risc
mixing up levels, IsSame is Mom at risc this is a minus and Zero check fix all tests
This commit is contained in:
@ -7,9 +7,10 @@ module Risc
|
||||
def setup
|
||||
super
|
||||
@input = "if(@a) ; arg = 5 ; else; arg = 6; end"
|
||||
@expect = [SlotToReg, SlotToReg, LoadConstant, IsSame, LoadConstant, IsSame ,
|
||||
Label, LoadConstant, SlotToReg, RegToSlot, Unconditional, Label ,
|
||||
LoadConstant, SlotToReg, RegToSlot, Label]
|
||||
@expect = [SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsNotZero ,
|
||||
LoadConstant, OperatorInstruction, IsNotZero, Label, LoadConstant ,
|
||||
SlotToReg, RegToSlot, Unconditional, Label, LoadConstant ,
|
||||
SlotToReg, RegToSlot, Label]
|
||||
end
|
||||
|
||||
def test_if_instructions
|
||||
@ -22,30 +23,30 @@ module Risc
|
||||
end
|
||||
def test_false_check
|
||||
produced = produce_body
|
||||
assert_equal produced.next(11) , produced.next(3).label
|
||||
assert_equal produced.next(13) , produced.next(4).label
|
||||
end
|
||||
def test_nil_load
|
||||
produced = produce_body
|
||||
assert_equal Mom::NilConstant , produced.next(4).constant.class
|
||||
assert_equal Mom::NilConstant , produced.next(5).constant.class
|
||||
end
|
||||
def test_nil_check
|
||||
produced = produce_body
|
||||
assert_equal produced.next(11) , produced.next(5).label
|
||||
assert_equal produced.next(13) , produced.next(7).label
|
||||
end
|
||||
|
||||
def test_true_label
|
||||
produced = produce_body
|
||||
assert produced.next(6).name.start_with?("true_label")
|
||||
assert produced.next(8).name.start_with?("true_label")
|
||||
end
|
||||
|
||||
def test_merge_label
|
||||
produced = produce_body
|
||||
assert produced.next(15).name.start_with?("merge_label")
|
||||
assert produced.next(17).name.start_with?("merge_label")
|
||||
end
|
||||
|
||||
def test_true_jump # should jumpp to merge label
|
||||
produced = produce_body
|
||||
assert produced.next(10).label.name.start_with?("merge_label")
|
||||
assert produced.next(12).label.name.start_with?("merge_label")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user