bit of organising

This commit is contained in:
Torsten Ruger
2018-04-23 13:16:46 +03:00
parent 020bce740a
commit 1907574c60
15 changed files with 15 additions and 15 deletions

View File

@ -0,0 +1,59 @@
require_relative "../helper"
module Risc
class InterpreterWhileCount < MiniTest::Test
include Ticker
def setup
@string_input = as_main 'a = 0; while( 0 > a); a = 1 + a;end;return a'
super
end
def test_if
#show_main_ticks # get output of what is in main
check_main_chain [Label, LoadConstant, SlotToReg, RegToSlot, Label,
LoadConstant, LoadConstant, SlotToReg, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, SlotToReg, RegToSlot,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, LoadConstant, FunctionCall, Label,
SlotToReg, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
OperatorInstruction, IsMinus, LoadConstant, Branch, Label,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, FunctionReturn, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero,
LoadConstant, OperatorInstruction, IsZero, LoadConstant, LoadConstant,
SlotToReg, RegToSlot, RegToSlot, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, SlotToReg, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
LoadConstant, FunctionCall, Label, SlotToReg, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, LoadConstant,
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
FunctionReturn, SlotToReg, SlotToReg, RegToSlot, Branch,
Label, LoadConstant, LoadConstant, SlotToReg, RegToSlot,
RegToSlot, SlotToReg, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, RegToSlot, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant,
SlotToReg, RegToSlot, SlotToReg, LoadConstant, FunctionCall,
Label, SlotToReg, SlotToReg, SlotToReg, SlotToReg,
SlotToReg, OperatorInstruction, IsMinus, Label, LoadConstant,
Label, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, FunctionReturn, SlotToReg, SlotToReg,
RegToSlot, SlotToReg, SlotToReg, LoadConstant, OperatorInstruction,
IsZero, Label, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
FunctionReturn, Transfer, Syscall, NilClass]
assert_kind_of Parfait::Integer , get_return
assert_equal 1 , get_return.value
end
def test_exit
done = main_ticks(183)
assert_equal Syscall , done.class
end
end
end

View File

@ -0,0 +1,59 @@
require_relative "../helper"
module Risc
class InterpreterWhileSimle < MiniTest::Test
include Ticker
def setup
@string_input = as_main 'a = true; while( a ); a = false;end;return a'
super
end
def test_if
#show_main_ticks # get output of what is in main
check_main_chain [Label, LoadConstant, SlotToReg, RegToSlot, Label,
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, IsZero,
LoadConstant, OperatorInstruction, IsZero, LoadConstant, SlotToReg,
RegToSlot, Branch, Label, SlotToReg, SlotToReg,
LoadConstant, OperatorInstruction, IsZero, Label, SlotToReg,
SlotToReg, RegToSlot, SlotToReg, SlotToReg, RegToSlot,
SlotToReg, SlotToReg, FunctionReturn, Transfer, Syscall,
NilClass]
assert_kind_of Parfait::FalseClass , get_return
end
def test_load_false_const
load = main_ticks(2)
assert_equal LoadConstant , load.class
assert_kind_of Parfait::TrueClass , load.constant
end
def test_load_false
load = main_ticks(8)
assert_equal LoadConstant , load.class
assert_equal Parfait::FalseClass , load.constant.class
end
def test_compare
op = main_ticks(9)
assert_equal OperatorInstruction , op.class
assert_equal :- , op.operator
end
def test_not_zero
check = main_ticks(10)
assert_equal IsZero , check.class
assert check.label.name.start_with?("merge_label") , check.label.name
end
def test_compare2
op = main_ticks(12)
assert_equal OperatorInstruction , op.class
assert_equal :- , op.operator
end
def test_not_zero2
check = main_ticks(13)
assert_equal IsZero , check.class
assert check.label.name.start_with?("merge_label") , check.label.name
end
def test_exit
done = main_ticks(35)
assert_equal Syscall , done.class
end
end
end