fix tests (from changing MethodSetup)

This commit is contained in:
Torsten Ruger 2018-04-03 14:31:49 +03:00
parent 17b52d4e80
commit 0a075c0f8a
3 changed files with 40 additions and 41 deletions

View File

@ -62,11 +62,8 @@ module Risc
postamble.each {all.pop} postamble.each {all.pop}
str = all.collect{|i| i.class.name}.join(", ").gsub("Risc::","") str = all.collect{|i| i.class.name}.join(", ").gsub("Risc::","")
str = "[#{str}]" str = "[#{str}]"
ret = "" all = str.split(",").each_slice(5).collect { |line| " " + line.join(",")}
str.split(",").each_slice(5).each do |line| all.join(",\n")
ret += " " + line.join(",") + ",\n"
end
ret
end end
end end
end end

View File

@ -7,22 +7,22 @@ module Risc
def setup def setup
super super
@input = "return @a.mod4" @input = "return @a.mod4"
@expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction , @expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction,
IsZero, SlotToReg, SlotToReg, LoadConstant, RegToSlot , IsZero, SlotToReg, SlotToReg, LoadConstant, RegToSlot,
LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant , LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot , SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg , LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg , RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg , SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label , SlotToReg, RegToSlot, SlotToReg, LoadConstant, FunctionCall,
SlotToReg, LoadConstant, RegToSlot, Label, LoadConstant , Label, SlotToReg, LoadConstant, RegToSlot, Label,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg , LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant , SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot , LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant , RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, DynamicJump, SlotToReg, SlotToReg, RegToSlot , LoadConstant, SlotToReg, DynamicJump, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg , RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, FunctionReturn] SlotToReg, RegToSlot, SlotToReg, SlotToReg, FunctionReturn]
end end
def test_return_instructions def test_return_instructions
@ -30,7 +30,7 @@ module Risc
end end
def test_function_return def test_function_return
produced = produce_body produced = produce_body
assert_equal FunctionReturn , produced.next(78).class assert_equal FunctionReturn , produced.next(79).class
end end
def test_cache_check def test_cache_check
produced = produce_body produced = produce_body

View File

@ -7,18 +7,20 @@ module Risc
def setup def setup
super super
@input = "@a.mod4" @input = "@a.mod4"
@expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, IsZero , @expect = [LoadConstant, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction,
SlotToReg, SlotToReg, LoadConstant, RegToSlot, LoadConstant, SlotToReg , IsZero, SlotToReg, SlotToReg, LoadConstant, RegToSlot,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, SlotToReg , LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, SlotToReg , SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg , LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot , RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, LoadConstant, FunctionCall, Label, SlotToReg, LoadConstant , SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
RegToSlot, Label, LoadConstant, SlotToReg, SlotToReg, RegToSlot , SlotToReg, RegToSlot, SlotToReg, LoadConstant, FunctionCall,
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot , Label, SlotToReg, LoadConstant, RegToSlot, Label,
LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot , LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg , SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
DynamicJump] LoadConstant, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, DynamicJump]
end end
def test_send_instructions def test_send_instructions
@ -26,23 +28,23 @@ module Risc
end end
def test_function_call def test_function_call
produced = produce_body produced = produce_body
assert_equal DynamicJump , produced.next(66).class assert_equal DynamicJump , produced.next(67).class
end end
def test_load_address def test_load_address
produced = produce_body produced = produce_body
assert_equal LoadConstant , produced.next(64).class assert_equal LoadConstant , produced.next(65).class
assert_equal Parfait::CacheEntry , produced.next(64).constant.class assert_equal Parfait::CacheEntry , produced.next(65).constant.class
end end
def test_cache_check def test_cache_check
produced = produce_body produced = produce_body
assert_equal IsZero , produced.next(5).class assert_equal IsZero , produced.next(5).class
assert_equal Label , produced.next(43).class assert_equal Label , produced.next(44).class
assert_equal produced.next(43) , produced.next(5).label assert_equal produced.next(44) , produced.next(5).label
end end
def test_check_resolve def test_check_resolve
produced = produce_body produced = produce_body
assert_equal FunctionCall , produced.next(38).class assert_equal FunctionCall , produced.next(39).class
assert_equal :resolve_method ,produced.next(38).method.name assert_equal :resolve_method ,produced.next(39).method.name
end end
end end
end end