fix all mom tests

still quite brittle, but easy to fix
This commit is contained in:
2019-08-23 19:24:18 +03:00
parent 1eb6430880
commit 4656ea8ffb
19 changed files with 93 additions and 86 deletions

View File

@ -7,12 +7,13 @@ module Risc
def setup
super
@input = "while(5 > 0) ; @a = true; end;return"
@expect = [Label, LoadConstant, RegToSlot, LoadConstant, SlotToReg, #4
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #9
SlotToReg, RegToSlot, SlotToReg, FunctionCall, Label, #14
SlotToReg, LoadConstant, OperatorInstruction, IsZero, LoadConstant, #19
OperatorInstruction, IsZero, LoadConstant, SlotToReg, RegToSlot, #24
Branch, Label, LoadConstant, RegToSlot, Branch,] #29
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #5
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #10
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, #15
Label, SlotToReg, LoadConstant, OperatorInstruction, IsZero, #20
LoadConstant, OperatorInstruction, IsZero, LoadConstant, SlotToReg, #25
RegToSlot, Branch, Label, LoadConstant, RegToSlot, #30
Branch,] #35
end
def test_while_instructions
@ -23,33 +24,33 @@ module Risc
end
def test_int_load_5
produced = produce_body
load = produced.next(3)
load = produced.next(4)
assert_equal Risc::LoadConstant , load.class
assert_equal Parfait::Integer , load.constant.class
assert_equal 5 , load.constant.value
end
def test_int_load_0
produced = produce_body
load = produced.next(6)
load = produced.next(7)
assert_equal Risc::LoadConstant , load.class
assert_equal Parfait::Integer , load.constant.class
assert_equal 0 , load.constant.value
end
def test_false_check
produced = produce_body
assert_equal Risc::IsZero , produced.next(18).class
assert produced.next(18).label.name.start_with?("merge_label") , produced.next(18).label.name
assert_equal Risc::IsZero , produced.next(19).class
assert produced.next(19).label.name.start_with?("merge_label") , produced.next(19).label.name
end
def test_nil_load
produced = produce_body
assert_equal Risc::LoadConstant , produced.next(22).class
assert_equal Parfait::TrueClass , produced.next(22).constant.class
assert_equal Risc::LoadConstant , produced.next(23).class
assert_equal Parfait::TrueClass , produced.next(23).constant.class
end
def ttest_back_jump # should jump back to condition label
def test_back_jump # should jump back to condition label
produced = produce_body
assert_equal Risc::Branch , produced.next(31).class
assert_equal produced.name , produced.next(31).label.name
assert_equal Risc::Branch , produced.next(26).class
assert_equal produced.name , produced.next(26).label.name
end
end