CC change test fixes finished

This commit is contained in:
Torsten Rüger 2019-08-23 19:25:02 +03:00
parent 4656ea8ffb
commit 86b27ab319
18 changed files with 181 additions and 173 deletions

View File

@ -11,23 +11,24 @@ module Risc
def test_chain def test_chain
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, LoadConstant, RegToSlot, SlotToReg, #5 check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #10 SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #10
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, #15 RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #15
LoadConstant, SlotToReg, OperatorInstruction, IsZero, SlotToReg, #20 FunctionCall, LoadConstant, SlotToReg, OperatorInstruction, IsZero, #20
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, #25 SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #25
LoadConstant, RegToSlot, SlotToReg, SlotToReg, DynamicJump, #30 RegToSlot, SlotToReg, LoadConstant, RegToSlot, SlotToReg, #30
LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant, #35 SlotToReg, DynamicJump, LoadConstant, SlotToReg, SlotToReg, #35
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, #40 RegToSlot, LoadConstant, RegToSlot, Branch, SlotToReg, #40
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, #45 SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #45
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, #50 FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #50
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, #55 SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #55
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, #60 FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #60
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer, #65 SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #65
SlotToReg, SlotToReg, Syscall, NilClass,] #70 FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, #70
NilClass,] #75
assert_equal 10 , get_return assert_equal 10 , get_return
end end
def base ; 30 ; end def base ; 32 ; end
def test_block_jump def test_block_jump
load_ins = main_ticks(base) load_ins = main_ticks(base)

View File

@ -11,30 +11,31 @@ module Risc
def test_chain def test_chain
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, SlotToReg, SlotToReg, RegToSlot, #5 check_main_chain [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #5
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #10
RegToSlot, SlotToReg, FunctionCall, LoadConstant, SlotToReg, #15 SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, #15
OperatorInstruction, IsZero, SlotToReg, RegToSlot, SlotToReg, #20 SlotToReg, OperatorInstruction, IsZero, SlotToReg, SlotToReg, #20
SlotToReg, RegToSlot, SlotToReg, LoadConstant, RegToSlot, #25 RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, #25
SlotToReg, SlotToReg, DynamicJump, LoadConstant, RegToSlot, #30 LoadConstant, RegToSlot, SlotToReg, SlotToReg, DynamicJump, #30
Branch, SlotToReg, SlotToReg, RegToSlot, SlotToReg, #35 LoadConstant, RegToSlot, Branch, SlotToReg, SlotToReg, #35
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, RegToSlot, #40 RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #40
Branch, SlotToReg, SlotToReg, RegToSlot, SlotToReg, #45 SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #45
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, RegToSlot, #50 RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #50
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #55 SlotToReg, RegToSlot, SlotToReg, RegToSlot, Branch, #55
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #60 SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #60
Transfer, SlotToReg, SlotToReg, Syscall, NilClass,] #65 SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, #65
Syscall, NilClass,] #70
assert_equal 15 , get_return assert_equal 15 , get_return
end end
def test_load_return def test_load_return
load_ins = main_ticks(24) load_ins = main_ticks(26)
assert_equal LoadConstant , load_ins.class assert_equal LoadConstant , load_ins.class
assert_equal Parfait::ReturnAddress , @interpreter.get_register(load_ins.register).class assert_equal Parfait::ReturnAddress , @interpreter.get_register(load_ins.register).class
end end
def test_load_block def test_load_block
load_ins = main_ticks(28) load_ins = main_ticks(30)
assert_equal DynamicJump , load_ins.class assert_equal DynamicJump , load_ins.class
assert_equal Parfait::Block , @interpreter.get_register(load_ins.register).class assert_equal Parfait::Block , @interpreter.get_register(load_ins.register).class
assert_equal :main_block , @interpreter.get_register(load_ins.register).name assert_equal :main_block , @interpreter.get_register(load_ins.register).name

View File

@ -12,23 +12,24 @@ module Risc
def test_chain def test_chain
# show_main_ticks # get output of what is # show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5 check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #10
RegToSlot, SlotToReg, FunctionCall, LoadConstant, SlotToReg, #15 SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, #15
LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, RegToSlot, #20 SlotToReg, LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, #20
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, #25 RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, #25
RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, #30 OperatorInstruction, RegToSlot, RegToSlot, SlotToReg, SlotToReg, #30
Branch, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #35 Branch, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #35
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #40 FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #40
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #45 SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #45
Transfer, SlotToReg, SlotToReg, Syscall, NilClass,] #50 FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, #50
NilClass,] #55
assert_equal 10 , get_return assert_equal 10 , get_return
end end
def base_ticks(num) def base_ticks(num)
main_ticks(13 + num) main_ticks(14 + num)
end end
def test_base def test_base
assert_equal FunctionCall , main_ticks( 13 ).class assert_equal FunctionCall , main_ticks( 14 ).class
end end
def test_load_factory def test_load_factory
lod = base_ticks( 1 ) lod = base_ticks( 1 )

View File

@ -11,32 +11,32 @@ module Risc
def test_chain def test_chain
# show_main_ticks # get output of what is # show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5 check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, #10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #10
LoadConstant, SlotToReg, LoadConstant, OperatorInstruction, IsNotZero, #15 FunctionCall, LoadConstant, SlotToReg, LoadConstant, OperatorInstruction, #15
SlotToReg, RegToSlot, SlotToReg, SlotToReg, Transfer, #20 IsNotZero, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #20
Transfer, LoadData, OperatorInstruction, LoadData, OperatorInstruction, #25 Transfer, Transfer, LoadData, OperatorInstruction, LoadData, #25
OperatorInstruction, LoadData, Branch, Transfer, OperatorInstruction, #30 OperatorInstruction, OperatorInstruction, Branch, LoadData, Transfer, #30
OperatorInstruction, LoadData, Transfer, OperatorInstruction, OperatorInstruction, #35 OperatorInstruction, OperatorInstruction, LoadData, Transfer, OperatorInstruction, #35
LoadData, Transfer, OperatorInstruction, OperatorInstruction, LoadData, #40 OperatorInstruction, LoadData, Transfer, OperatorInstruction, OperatorInstruction, #40
OperatorInstruction, LoadData, Transfer, OperatorInstruction, OperatorInstruction, #45 LoadData, OperatorInstruction, LoadData, Transfer, OperatorInstruction, #45
Transfer, LoadData, OperatorInstruction, LoadData, OperatorInstruction, #50 OperatorInstruction, Transfer, LoadData, OperatorInstruction, LoadData, #50
OperatorInstruction, RegToSlot, RegToSlot, SlotToReg, SlotToReg, #55 OperatorInstruction, OperatorInstruction, RegToSlot, RegToSlot, SlotToReg, #55
RegToSlot, SlotToReg, Branch, SlotToReg, SlotToReg, #60 SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #60
FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #65 SlotToReg, FunctionReturn, SlotToReg, RegToSlot, Branch, #65
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #70 SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #70
FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, #75 SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, #75
NilClass,] #80s Syscall, NilClass,] #80
assert_equal 2 , get_return assert_equal 2 , get_return
end end
def test_load_25 def test_load_25
load_ins = main_ticks 3 load_ins = main_ticks 4
assert_equal LoadConstant , load_ins.class assert_equal LoadConstant , load_ins.class
assert_equal 25 , @interpreter.get_register(load_ins.register).value assert_equal 25 , @interpreter.get_register(load_ins.register).value
end end
def test_return_class def test_return_class
ret = main_ticks(71) ret = main_ticks(72)
assert_equal FunctionReturn , ret.class assert_equal FunctionReturn , ret.class
link = @interpreter.get_register( ret.register ) link = @interpreter.get_register( ret.register )
assert_equal ::Integer , link.class assert_equal ::Integer , link.class

View File

@ -10,20 +10,20 @@ module Risc
end end
def test_chain def test_chain
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5 check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #10
RegToSlot, SlotToReg, FunctionCall, LoadConstant, SlotToReg, #15 SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, #15
LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, RegToSlot, #20 SlotToReg, LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, #20
SlotToReg, SlotToReg, SlotToReg, ByteToReg, RegToSlot, #25 RegToSlot, SlotToReg, SlotToReg, SlotToReg, ByteToReg, #25
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg, #30 RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, #30
Branch, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, #35 Branch, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #35
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, #40 SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #40
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer, #45 RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #45
SlotToReg, SlotToReg, Syscall, NilClass,] #50 Transfer, SlotToReg, SlotToReg, Syscall, NilClass,] #50
assert_equal "H".ord , get_return assert_equal "H".ord , get_return
end end
def test_byte_to_reg def test_byte_to_reg
done = main_ticks(24) done = main_ticks(25)
assert_equal ByteToReg , done.class assert_equal ByteToReg , done.class
assert_equal "H".ord , @interpreter.get_register(done.register) assert_equal "H".ord , @interpreter.get_register(done.register)
end end

View File

@ -11,20 +11,21 @@ module Risc
def test_minus def test_minus
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5 check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #10
RegToSlot, SlotToReg, FunctionCall, LoadConstant, SlotToReg, #15 SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, #15
LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, RegToSlot, #20 SlotToReg, LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, #20
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, #25 RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, #25
RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, #30 OperatorInstruction, RegToSlot, RegToSlot, SlotToReg, SlotToReg, #30
Branch, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #35 Branch, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #35
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #40 FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #40
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #45 SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #45
Transfer, SlotToReg, SlotToReg, Syscall, NilClass,] #50 FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, #50
NilClass,] #55
assert_equal 1 , get_return assert_equal 1 , get_return
end end
def test_op def test_op
op = main_ticks(25) op = main_ticks(26)
assert_equal OperatorInstruction , op.class assert_equal OperatorInstruction , op.class
assert_equal :- , op.operator assert_equal :- , op.operator
assert_equal :r2 , op.left.symbol assert_equal :r2 , op.left.symbol
@ -33,10 +34,10 @@ module Risc
assert_equal 5 , @interpreter.get_register(:r3) assert_equal 5 , @interpreter.get_register(:r3)
end end
def test_return def test_return
ret = main_ticks(45) ret = main_ticks(46)
assert_equal FunctionReturn , ret.class assert_equal FunctionReturn , ret.class
assert_equal :r3 , ret.register.symbol assert_equal :r3 , ret.register.symbol
assert_equal 26008 , @interpreter.get_register(ret.register) assert_equal 26012 , @interpreter.get_register(ret.register)
end end
end end
end end

View File

@ -11,21 +11,21 @@ module Risc
def test_chain def test_chain
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5 check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, #10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #10
LoadConstant, SlotToReg, LoadConstant, OperatorInstruction, IsNotZero, #15 FunctionCall, LoadConstant, SlotToReg, LoadConstant, OperatorInstruction, #15
SlotToReg, RegToSlot, SlotToReg, SlotToReg, LoadData, #20 IsNotZero, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #20
OperatorInstruction, RegToSlot, RegToSlot, SlotToReg, SlotToReg, #25 LoadData, OperatorInstruction, RegToSlot, RegToSlot, SlotToReg, #25
RegToSlot, SlotToReg, Branch, SlotToReg, SlotToReg, #30 SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #30
FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #35 SlotToReg, FunctionReturn, SlotToReg, RegToSlot, Branch, #35
SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #40 SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #40
FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, #45 SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, #45
NilClass,] #50 Syscall, NilClass,] #50
assert_equal 2 , get_return assert_equal 2 , get_return
end end
def test_op def test_op
op = main_ticks(21) op = main_ticks(22)
assert_equal OperatorInstruction , op.class assert_equal OperatorInstruction , op.class
assert_equal :>> , op.operator assert_equal :>> , op.operator
assert_equal :r2 , op.left.symbol assert_equal :r2 , op.left.symbol

View File

@ -11,16 +11,17 @@ module Risc
def test_mult def test_mult
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5 check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #10
RegToSlot, SlotToReg, FunctionCall, LoadConstant, SlotToReg, #15 SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, #15
LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, RegToSlot, #20 SlotToReg, LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, #20
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, #25 RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, #25
RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, #30 OperatorInstruction, RegToSlot, RegToSlot, SlotToReg, SlotToReg, #30
Branch, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #35 Branch, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #35
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #40 FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #40
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #45 SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #45
Transfer, SlotToReg, SlotToReg, Syscall, NilClass,] #50 FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, #50
NilClass,] #55
assert_equal 0 , get_return assert_equal 0 , get_return
end end
def test_zero def test_zero
@ -28,7 +29,7 @@ module Risc
assert @interpreter.flags[:zero] assert @interpreter.flags[:zero]
end end
def test_op def test_op
op = main_ticks(25) op = main_ticks(26)
assert_equal OperatorInstruction , op.class assert_equal OperatorInstruction , op.class
assert_equal :r2 , op.left.symbol assert_equal :r2 , op.left.symbol
assert_equal :r3 , op.right.symbol assert_equal :r3 , op.right.symbol

View File

@ -11,23 +11,24 @@ module Risc
def test_chain def test_chain
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5 check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #10
RegToSlot, SlotToReg, FunctionCall, LoadConstant, SlotToReg, #15 SlotToReg, RegToSlot, SlotToReg, FunctionCall, LoadConstant, #15
LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, RegToSlot, #20 SlotToReg, LoadConstant, OperatorInstruction, IsNotZero, SlotToReg, #20
SlotToReg, SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, #25 RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg, #25
RegToSlot, RegToSlot, SlotToReg, SlotToReg, RegToSlot, #30 OperatorInstruction, RegToSlot, RegToSlot, SlotToReg, SlotToReg, #30
Branch, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #35 Branch, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #35
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #40 FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #40
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #45 SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #45
Transfer, SlotToReg, SlotToReg, Syscall, NilClass,] #50 FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, #50
NilClass,] #55
assert_equal 10 , get_return assert_equal 10 , get_return
end end
def base_ticks(num) def base_ticks(num)
main_ticks(13 + num) main_ticks(14 + num)
end end
def test_base def test_base
cal = main_ticks( 13 ) cal = main_ticks( 14 )
assert_equal FunctionCall , cal.class assert_equal FunctionCall , cal.class
end end
def test_load_receiver def test_load_receiver

View File

@ -11,27 +11,27 @@ module Risc
def test_chain def test_chain
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5 check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
LoadConstant, SlotToReg, RegToSlot, SlotToReg, FunctionCall, #10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #10
LoadConstant, SlotToReg, LoadConstant, OperatorInstruction, IsNotZero, #15 FunctionCall, LoadConstant, SlotToReg, LoadConstant, OperatorInstruction, #15
SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg, #20 IsNotZero, SlotToReg, RegToSlot, RegToSlot, SlotToReg, #20
Transfer, Syscall, Transfer, Transfer, SlotToReg, #25 SlotToReg, Transfer, Syscall, Transfer, Transfer, #25
RegToSlot, SlotToReg, Branch, SlotToReg, RegToSlot, #30 SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #30
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, SlotToReg, #35 RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #35
RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, #40 SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #40
SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer, #45 RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #45
SlotToReg, SlotToReg, Syscall, NilClass,] #50 Transfer, SlotToReg, SlotToReg, Syscall, NilClass,] #50
assert_equal "Hello again" , @interpreter.stdout assert_equal "Hello again" , @interpreter.stdout
assert_equal 11 , get_return #bytes written assert_equal 11 , get_return #bytes written
end end
def test_call def test_call
cal = main_ticks(10) cal = main_ticks(11)
assert_equal FunctionCall , cal.class assert_equal FunctionCall , cal.class
assert_equal :putstring , cal.method.name assert_equal :putstring , cal.method.name
end end
def test_putstring_sys def test_putstring_sys
done = main_ticks(22) done = main_ticks(23)
assert_equal Syscall , done.class assert_equal Syscall , done.class
assert_equal "Hello again" , @interpreter.stdout assert_equal "Hello again" , @interpreter.stdout
assert_equal 11 , @interpreter.get_register(:r0) assert_equal 11 , @interpreter.get_register(:r0)
@ -44,16 +44,16 @@ module Risc
assert_equal 11 , @interpreter.get_register(:r3) assert_equal 11 , @interpreter.get_register(:r3)
end end
def test_restore_message def test_restore_message
sl = main_ticks(24) sl = main_ticks(25)
assert_transfer(sl, :r8 ,:r0) assert_transfer(sl, :r8 ,:r0)
assert_equal Parfait::Message , @interpreter.get_register(:r0).class assert_equal Parfait::Message , @interpreter.get_register(:r0).class
end end
def test_move_sys_return def test_move_sys_return
sl = main_ticks(30) sl = main_ticks(31)
assert_reg_to_slot( sl , :r1 ,:r2 , 5) assert_reg_to_slot( sl , :r1 ,:r2 , 5)
end end
def test_return def test_return
done = main_ticks(44) done = main_ticks(45)
assert_equal FunctionReturn , done.class assert_equal FunctionReturn , done.class
end end

View File

@ -11,19 +11,20 @@ module Risc
def test_chain def test_chain
#show_main_ticks # get output of what is #show_main_ticks # get output of what is
check_main_chain [LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #5 check_main_chain [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #5
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #10 RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant, #10
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #15 SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #15
FunctionCall, SlotToReg, SlotToReg, RegToSlot, SlotToReg, #20 SlotToReg, FunctionCall, SlotToReg, SlotToReg, RegToSlot, #20
SlotToReg, SlotToReg, RegToByte, SlotToReg, SlotToReg, #25 SlotToReg, SlotToReg, SlotToReg, RegToByte, SlotToReg, #25
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #30 SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #30
SlotToReg, RegToSlot, Branch, SlotToReg, SlotToReg, #35 FunctionReturn, SlotToReg, RegToSlot, Branch, SlotToReg, #35
RegToSlot, SlotToReg, SlotToReg, SlotToReg, FunctionReturn, #40 SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg, #40
Transfer, SlotToReg, SlotToReg, Syscall, NilClass,] #45 FunctionReturn, Transfer, SlotToReg, SlotToReg, Syscall, #45
NilClass,] #50
assert_equal "K".ord , get_return assert_equal "K".ord , get_return
end end
def test_reg_to_byte def test_reg_to_byte
done = main_ticks(23) done = main_ticks(24)
assert_equal RegToByte , done.class assert_equal RegToByte , done.class
assert_equal "K".ord , @interpreter.get_register(done.register) assert_equal "K".ord , @interpreter.get_register(done.register)
end end

View File

@ -24,17 +24,16 @@ module Risc
IsZero, SlotToReg, OperatorInstruction, IsZero, SlotToReg, #55 IsZero, SlotToReg, OperatorInstruction, IsZero, SlotToReg, #55
Branch, LoadConstant, OperatorInstruction, IsZero, SlotToReg, #60 Branch, LoadConstant, OperatorInstruction, IsZero, SlotToReg, #60
OperatorInstruction, IsZero, RegToSlot, LoadConstant, SlotToReg, #65 OperatorInstruction, IsZero, RegToSlot, LoadConstant, SlotToReg, #65
RegToSlot, SlotToReg, SlotToReg, RegToSlot, LoadConstant, #70 SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot, #70
SlotToReg, RegToSlot, SlotToReg, LoadConstant, SlotToReg, #75 LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, #75
DynamicJump, LoadConstant, SlotToReg, LoadConstant, OperatorInstruction, #80 SlotToReg, DynamicJump, LoadConstant, SlotToReg, LoadConstant, #80
IsNotZero, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #85 OperatorInstruction, IsNotZero, SlotToReg, RegToSlot, SlotToReg, #85
LoadData, OperatorInstruction, RegToSlot, RegToSlot, SlotToReg, #90 SlotToReg, LoadData, OperatorInstruction, RegToSlot, RegToSlot, #90
SlotToReg, RegToSlot, SlotToReg, Branch, SlotToReg, #95 SlotToReg, SlotToReg, RegToSlot, Branch, SlotToReg, #95
SlotToReg, FunctionReturn, SlotToReg, RegToSlot, Branch, #100 SlotToReg, SlotToReg, FunctionReturn, SlotToReg, RegToSlot, #100
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #105 Branch, SlotToReg, SlotToReg, RegToSlot, SlotToReg, #105
SlotToReg, FunctionReturn, Transfer, SlotToReg, SlotToReg, #110 SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, #110
Syscall, NilClass,] #115 SlotToReg, Syscall, NilClass,] #115
assert_equal ::Integer , get_return.class assert_equal ::Integer , get_return.class
assert_equal 1 , get_return assert_equal 1 , get_return
end end
@ -51,17 +50,17 @@ module Risc
end end
def test_dyn def test_dyn
cal = main_ticks(76) cal = main_ticks(77)
assert_equal DynamicJump , cal.class assert_equal DynamicJump , cal.class
end end
def test_return def test_return
ret = main_ticks(107) ret = main_ticks(108)
assert_equal FunctionReturn , ret.class assert_equal FunctionReturn , ret.class
link = @interpreter.get_register( ret.register ) link = @interpreter.get_register( ret.register )
assert_equal ::Integer , link.class assert_equal ::Integer , link.class
end end
def test_sys def test_sys
sys = main_ticks(111) sys = main_ticks(112)
assert_equal Syscall , sys.class assert_equal Syscall , sys.class
end end
end end

View File

@ -19,7 +19,7 @@ module Risc
@instruction_events << was @instruction_events << was
end end
def length def length
27 28
end end
def test_state_change def test_state_change
@interpreter.register_event :state_changed , self @interpreter.register_event :state_changed , self
@ -40,12 +40,11 @@ module Risc
def test_chain def test_chain
#show_ticks # get output of what is #show_ticks # get output of what is
check_chain [Branch, LoadConstant, SlotToReg, SlotToReg, RegToSlot, #5 check_chain [Branch, LoadConstant, SlotToReg, SlotToReg, RegToSlot, #5
LoadConstant, RegToSlot, SlotToReg, LoadConstant, RegToSlot, #10 LoadConstant, SlotToReg, RegToSlot, SlotToReg, LoadConstant, #10
LoadConstant, RegToSlot, FunctionCall, LoadConstant, RegToSlot, #15 RegToSlot, LoadConstant, RegToSlot, FunctionCall, LoadConstant, #15
Branch, SlotToReg, SlotToReg, RegToSlot, SlotToReg, #20 RegToSlot, Branch, SlotToReg, SlotToReg, RegToSlot, #20
SlotToReg, SlotToReg, FunctionReturn, Transfer, SlotToReg, #25 SlotToReg, SlotToReg, SlotToReg, FunctionReturn, Transfer, #25
SlotToReg, Syscall, NilClass,] #30 SlotToReg, SlotToReg, Syscall, NilClass,] #30
assert_equal ::Integer , get_return.class assert_equal ::Integer , get_return.class
assert_equal 5 , get_return assert_equal 5 , get_return
end end

View File

@ -43,7 +43,7 @@ module Risc
end end
def test_allocate_len def test_allocate_len
int = @builder.allocate_int int = @builder.allocate_int
assert_equal 22 , @builder.compiler.risc_instructions.length assert_equal 23 , @builder.compiler.risc_instructions.length
end end
end end
end end

View File

@ -11,7 +11,7 @@ module Risc
def test_simple_collect def test_simple_collect
objects = Collector.collect_space(@linker) objects = Collector.collect_space(@linker)
assert_equal 619 , objects.length , objects.length.to_s assert_equal 601 , objects.length , objects.length.to_s
end end
def test_collect_all_types def test_collect_all_types

View File

@ -55,7 +55,7 @@ module Risc
end end
def test_pc1 def test_pc1
@interpreter.tick @interpreter.tick
assert_equal 25960 , @interpreter.pc assert_equal 25912 , @interpreter.pc
end end
def test_tick2 def test_tick2
@interpreter.tick @interpreter.tick
@ -69,7 +69,7 @@ module Risc
def test_pc2 def test_pc2
@interpreter.tick @interpreter.tick
@interpreter.tick @interpreter.tick
assert_equal 25964 , @interpreter.pc assert_equal 25916 , @interpreter.pc
end end
def ttest_tick_14_jump def ttest_tick_14_jump
30.times { @interpreter.tick ;puts @interpreter.instruction.class} 30.times { @interpreter.tick ;puts @interpreter.instruction.class}

View File

@ -25,17 +25,17 @@ module Risc
assert_equal 0 , Position.get(@linker.cpu_init).at assert_equal 0 , Position.get(@linker.cpu_init).at
end end
def test_cpu_at def test_cpu_at
assert_equal "0x5edc" , Position.get(@linker.cpu_init.first).to_s assert_equal "0x5dbc" , Position.get(@linker.cpu_init.first).to_s
end end
def test_cpu_label def test_cpu_label
assert_equal Position , Position.get(@linker.cpu_init.first).class assert_equal Position , Position.get(@linker.cpu_init.first).class
end end
def test_first_binary_jump def test_first_binary_jump
bin = Parfait.object_space.get_init.binary bin = Parfait.object_space.get_init.binary
assert 0 != bin.get_word(Parfait::BinaryCode.data_length) , "index 0 is 0 #{bin.inspect}" assert_equal 116 , bin.total_byte_length
end end
def test_second_binary_first def test_second_binary_first
bin = Parfait.object_space.get_init.binary.next_code bin = Parfait.object_space.get_init.binary
assert 0 != bin.get_word(0) , "index 0 is 0 #{bin.inspect}" assert 0 != bin.get_word(0) , "index 0 is 0 #{bin.inspect}"
end end
def test_positions_set def test_positions_set

View File

@ -42,7 +42,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
13 14
end end
def get_return def get_return
@ -115,7 +115,10 @@ module Risc
run_all run_all
end end
def run_all def run_all
@interpreter.tick while(@interpreter.instruction) while(@interpreter.instruction)
@interpreter.tick
#puts @interpreter.instruction
end
@interpreter.clock @interpreter.clock
end end