busy fixing tests

This commit is contained in:
Torsten Ruger 2018-05-24 19:38:48 +03:00
parent 183d4152d5
commit bf23883270
8 changed files with 39 additions and 44 deletions

View File

@ -11,8 +11,8 @@ module Risc
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label, RegToSlot, SlotToReg, FunctionCall, Label, SlotToReg,
SlotToReg, SlotToReg, RegToSlot] SlotToReg, RegToSlot]
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg

View File

@ -11,7 +11,7 @@ module Risc
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label] RegToSlot, SlotToReg, FunctionCall, Label]
end end
def test_send_instructions def test_send_instructions
@ -27,16 +27,16 @@ module Risc
end end
def test_call_reg_setup def test_call_reg_setup
produced = produce_body produced = produce_body
assert_equal produced.next(22).register , produced.next(23).register assert_equal :div4 , produced.next(22).method.name
end end
def test_function_call def test_function_call
produced = produce_body produced = produce_body
assert_equal FunctionCall , produced.next(23).class assert_equal FunctionCall , produced.next(22).class
assert_equal :div4 , produced.next(23).method.name assert_equal :div4 , produced.next(22).method.name
end end
def test_check_continue def test_check_continue
produced = produce_body produced = produce_body
assert produced.next(24).name.start_with?("continue_") assert produced.next(23).name.start_with?("continue_")
end end
#TODO check the message setup, type and frame moves #TODO check the message setup, type and frame moves
end end

View File

@ -12,7 +12,7 @@ module Risc
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
SlotToReg, LoadConstant, FunctionCall, Label] SlotToReg, FunctionCall, Label]
end end
def test_send_instructions def test_send_instructions
@ -61,14 +61,14 @@ module Risc
produced = produce_body produced = produce_body
assert_equal SlotToReg , produced.next(base+5).class assert_equal SlotToReg , produced.next(base+5).class
assert_equal :r0 , produced.next(base+5).array.symbol assert_equal :r0 , produced.next(base+5).array.symbol
assert_equal :r3 , produced.next(base+5).register.symbol assert_equal :r2 , produced.next(base+5).register.symbol
assert_equal 1 , produced.next(base+5).index assert_equal 1 , produced.next(base+5).index
end end
def test_store_ def test_store_
produced = produce_body produced = produce_body
assert_equal RegToSlot , produced.next(base+6).class assert_equal RegToSlot , produced.next(base+6).class
assert_equal :r3 , produced.next(base+6).array.symbol assert_equal :r2 , produced.next(base+6).array.symbol
assert_equal :r2 , produced.next(base+6).register.symbol assert_equal :r1 , produced.next(base+6).register.symbol
assert_equal 4 , produced.next(base+6).index assert_equal 4 , produced.next(base+6).index
end end
@ -82,16 +82,12 @@ module Risc
def test_function_call def test_function_call
produced = produce_body produced = produce_body
assert_equal FunctionCall , produced.next(base+9).class assert_equal FunctionCall , produced.next(base+8).class
assert_equal :get_internal_word , produced.next(base+9).method.name assert_equal :get_internal_word , produced.next(base+8).method.name
end
def test_call_reg_setup
produced = produce_body
assert_equal produced.next(base+8).register , produced.next(base+9).register
end end
def test_check_continue def test_check_continue
produced = produce_body produced = produce_body
assert produced.next(base+10).name.start_with?("continue_") assert produced.next(base+9).name.start_with?("continue_")
end end
#TODO check the message setup, type and frame moves #TODO check the message setup, type and frame moves
end end

View File

@ -12,7 +12,7 @@ module Risc
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label] RegToSlot, SlotToReg, FunctionCall, Label]
@produced = produce_body @produced = produce_body
end end

View File

@ -11,10 +11,10 @@ module Risc
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot, RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label, RegToSlot, SlotToReg, FunctionCall, Label, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, FunctionReturn]
SlotToReg, FunctionReturn]
end end
def test_return_instructions def test_return_instructions
@ -22,7 +22,7 @@ module Risc
end end
def test_function_return def test_function_return
produced = produce_body produced = produce_body
assert_equal FunctionReturn , produced.next(36).class assert_equal FunctionReturn , produced.next(35).class
end end
def test_load_5 def test_load_5
produced = produce_body produced = produce_body

View File

@ -12,11 +12,10 @@ module Risc
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label, RegToSlot, SlotToReg, FunctionCall, Label, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, LoadConstant,
LoadConstant, OperatorInstruction, IsZero, LoadConstant, OperatorInstruction, OperatorInstruction, IsZero, LoadConstant, OperatorInstruction, IsZero,
IsZero, LoadConstant, SlotToReg, RegToSlot, Branch, LoadConstant, SlotToReg, RegToSlot, Branch, Label]
Label]
end end
def test_while_instructions def test_while_instructions
@ -41,19 +40,19 @@ module Risc
end end
def test_false_check def test_false_check
produced = produce_body produced = produce_body
assert_equal Risc::IsZero , produced.next(37).class assert_equal Risc::IsZero , produced.next(36).class
assert produced.next(37).label.name.start_with?("merge_label") , produced.next(37).label.name assert produced.next(36).label.name.start_with?("merge_label") , produced.next(36).label.name
end end
def test_nil_load def test_nil_load
produced = produce_body produced = produce_body
assert_equal Risc::LoadConstant , produced.next(38).class assert_equal Risc::LoadConstant , produced.next(37).class
assert_equal Parfait::NilClass , produced.next(38).constant.class assert_equal Parfait::NilClass , produced.next(37).constant.class
end end
def test_back_jump # should jump back to condition label def test_back_jump # should jump back to condition label
produced = produce_body produced = produce_body
assert_equal Risc::Branch , produced.next(44).class assert_equal Risc::Branch , produced.next(43).class
assert_equal produced , produced.next(44).label assert_equal produced , produced.next(43).label
end end
end end

View File

@ -11,35 +11,35 @@ module Risc
def test_if def test_if
#show_main_ticks # get output of what is in main #show_main_ticks # get output of what is in main
check_main_chain [Label, LoadConstant, LoadConstant, OperatorInstruction, IsZero, check_main_chain [LoadConstant, LoadConstant, OperatorInstruction, IsZero, LoadConstant,
LoadConstant, OperatorInstruction, IsZero, Label, LoadConstant, OperatorInstruction, IsZero, LoadConstant, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, FunctionReturn,
SlotToReg, FunctionReturn, Transfer, Syscall, NilClass] Transfer, Syscall, NilClass]
assert_equal Parfait::Word , get_return.class assert_equal Parfait::Word , get_return.class
assert_equal "then" , get_return.to_string assert_equal "then" , get_return.to_string
end end
def test_load_10 def test_load_10
load = main_ticks(2) load = main_ticks(1)
assert_equal LoadConstant , load.class assert_equal LoadConstant , load.class
assert_equal 10 , load.constant.value assert_equal 10 , load.constant.value
end end
def test_load_false def test_load_false
load = main_ticks(3) load = main_ticks(2)
assert_equal LoadConstant , load.class assert_equal LoadConstant , load.class
assert_equal Parfait::FalseClass , load.constant.class assert_equal Parfait::FalseClass , load.constant.class
end end
def test_compare def test_compare
op = main_ticks(4) op = main_ticks(3)
assert_equal OperatorInstruction , op.class assert_equal OperatorInstruction , op.class
assert_equal :- , op.operator assert_equal :- , op.operator
end end
def test_not_zero def test_not_zero
check = main_ticks(5) check = main_ticks(4)
assert_equal IsZero , check.class assert_equal IsZero , check.class
assert check.label.name.start_with?("false_label") , check.label.name assert check.label.name.start_with?("false_label") , check.label.name
end end
def test_exit def test_exit
done = main_ticks(19) done = main_ticks(17)
assert_equal Syscall , done.class assert_equal Syscall , done.class
end end
end end

View File

@ -36,7 +36,7 @@ module Risc
# how many instruction up until the main starts, ie # how many instruction up until the main starts, ie
# ticks(main_at) will be the label for main # ticks(main_at) will be the label for main
def main_at def main_at
26 25
end end
def get_return def get_return