formatted interpreter tests
little helper to output the classes
This commit is contained in:
parent
dc3920580b
commit
5131e5d050
@ -10,4 +10,26 @@ module Ticker
|
|||||||
end
|
end
|
||||||
return last
|
return last
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_ticks
|
||||||
|
classes = []
|
||||||
|
error = nil
|
||||||
|
tick = 1
|
||||||
|
begin
|
||||||
|
while true and (classes.length < 100)
|
||||||
|
cl = ticks(1).class
|
||||||
|
tick += 1
|
||||||
|
classes << cl
|
||||||
|
break if cl == NilClass
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
puts "Error at tick #{tick}"
|
||||||
|
puts e
|
||||||
|
end
|
||||||
|
classes = classes.collect {|c| '"' + c.name.sub("Register::","") + '",' }
|
||||||
|
classes.each_slice(5).each do |line|
|
||||||
|
puts " " + line.join
|
||||||
|
end
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,14 +65,10 @@ class AddTest < MiniTest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_chain
|
def test_chain
|
||||||
["Branch" , "LoadConstant" , "GetSlot" , "SetSlot" , "RegisterTransfer" ,
|
["Branch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
|
||||||
# "GetSlot" , "FunctionCall" , "SaveReturn" , "LoadConstant" , "LoadConstant" ,
|
"GetSlot","FunctionCall","SaveReturn","LoadConstant","LoadConstant",
|
||||||
# "OperatorInstruction" , "RegisterTransfer" , "GetSlot" , "LoadConstant" , "SetSlot" ,
|
"OperatorInstruction","RegisterTransfer","GetSlot"].each_with_index do |name , index|
|
||||||
# "LoadConstant" , "SetSlot" , "GetSlot" , "SetSlot", "RegisterTransfer" , "GetSlot" , "FunctionCall" ,
|
|
||||||
# "SaveReturn" , "GetSlot", "OperatorInstruction" , "RegisterTransfer" , "GetSlot" , "GetSlot" ,
|
|
||||||
"GetSlot" , "FunctionCall" ,"SaveReturn" , "LoadConstant", "LoadConstant"].each_with_index do |name , index|
|
|
||||||
got = ticks(1)
|
got = ticks(1)
|
||||||
puts got
|
|
||||||
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -59,24 +59,23 @@ HERE
|
|||||||
Virtual.machine.run_before "Register::CallImplementation"
|
Virtual.machine.run_before "Register::CallImplementation"
|
||||||
@interpreter = Interpreter::Interpreter.new
|
@interpreter = Interpreter::Interpreter.new
|
||||||
@interpreter.start Virtual.machine.init
|
@interpreter.start Virtual.machine.init
|
||||||
# done = ticks(34)
|
["Branch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
|
||||||
["Branch" , "LoadConstant" , "GetSlot" , "SetSlot" , "RegisterTransfer" ,
|
"GetSlot","FunctionCall","SaveReturn","LoadConstant","GetSlot",
|
||||||
"GetSlot" , "FunctionCall" , "SaveReturn", "LoadConstant" , "GetSlot" ,
|
"SetSlot","LoadConstant","SetSlot","RegisterTransfer","GetSlot",
|
||||||
"SetSlot" , "LoadConstant" , "SetSlot" , "RegisterTransfer" , "GetSlot" ,
|
"FunctionCall","SaveReturn","GetSlot","LoadConstant","SetSlot",
|
||||||
"FunctionCall" ,"SaveReturn" , "GetSlot" , "LoadConstant" , "SetSlot" ,
|
"GetSlot","SetSlot","LoadConstant","SetSlot","GetSlot",
|
||||||
"GetSlot", "SetSlot", "LoadConstant" ,"SetSlot" , "GetSlot" ,
|
"SetSlot","RegisterTransfer","GetSlot","FunctionCall","SaveReturn",
|
||||||
"SetSlot", "RegisterTransfer", "GetSlot" , "FunctionCall" , "SaveReturn",
|
"GetSlot","LoadConstant","OperatorInstruction","SetSlot","GetSlot",
|
||||||
"GetSlot", "LoadConstant", "OperatorInstruction", "SetSlot", "GetSlot",
|
"OperatorInstruction","SetSlot","GetSlot","LoadConstant","OperatorInstruction",
|
||||||
"OperatorInstruction","SetSlot", "GetSlot", "LoadConstant", "OperatorInstruction",
|
"IsZeroBranch","GetSlot","SetSlot","LoadConstant","SetSlot",
|
||||||
"Branch", "GetSlot", "SetSlot", "LoadConstant", "SetSlot",
|
"GetSlot","SetSlot","RegisterTransfer","GetSlot","FunctionCall",
|
||||||
"GetSlot", "SetSlot", "RegisterTransfer", "GetSlot", "FunctionCall",
|
"SaveReturn","GetSlot","LoadConstant","OperatorInstruction","IsZeroBranch",
|
||||||
"SaveReturn", "GetSlot", "LoadConstant", "OperatorInstruction","Branch",
|
"LoadConstant","GetSlot","LoadConstant","OperatorInstruction","IsZeroBranch",
|
||||||
"LoadConstant", "GetSlot", "LoadConstant", "OperatorInstruction","Branch",
|
"LoadConstant","GetSlot","LoadConstant","OperatorInstruction","IsZeroBranch",
|
||||||
"LoadConstant", "GetSlot", "LoadConstant", "OperatorInstruction","Branch",
|
"LoadConstant","GetSlot","LoadConstant","OperatorInstruction","IsZeroBranch",
|
||||||
"LoadConstant", "GetSlot", "LoadConstant", "OperatorInstruction","Branch",
|
"LoadConstant","GetSlot","LoadConstant","OperatorInstruction","IsZeroBranch",
|
||||||
"LoadConstant"].each_with_index do |name , index|
|
"LoadConstant","NilClass"].each_with_index do |name , index|
|
||||||
got = ticks(1)
|
got = ticks(1)
|
||||||
puts got
|
|
||||||
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,13 +55,14 @@ class TestPuts < MiniTest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_chain
|
def test_chain
|
||||||
["Branch" , "LoadConstant" , "GetSlot" , "SetSlot" , "RegisterTransfer" ,
|
show_ticks
|
||||||
"GetSlot" , "FunctionCall" , "SaveReturn" , "LoadConstant" , "GetSlot" ,
|
["Branch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
|
||||||
"SetSlot" , "LoadConstant" , "SetSlot" , "RegisterTransfer" , "GetSlot" ,
|
"GetSlot","FunctionCall","SaveReturn","LoadConstant","GetSlot",
|
||||||
"FunctionCall" , "SaveReturn" , "RegisterTransfer" , "Syscall" , "RegisterTransfer" ,
|
"SetSlot","LoadConstant","SetSlot","RegisterTransfer","GetSlot",
|
||||||
"RegisterTransfer" , "SetSlot" , "GetSlot" , "GetSlot" , "RegisterTransfer" ,
|
"FunctionCall","SaveReturn","RegisterTransfer","Syscall","RegisterTransfer",
|
||||||
"GetSlot" , "GetSlot" ,"GetSlot" , "FunctionReturn","RegisterTransfer",
|
"RegisterTransfer","SetSlot","GetSlot","GetSlot","RegisterTransfer",
|
||||||
"Syscall" , "NilClass"].each_with_index do |name , index|
|
"GetSlot","GetSlot","GetSlot","FunctionReturn","RegisterTransfer",
|
||||||
|
"Syscall","NilClass"].each_with_index do |name , index|
|
||||||
got = ticks(1)
|
got = ticks(1)
|
||||||
#puts "TICK #{index}"
|
#puts "TICK #{index}"
|
||||||
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
||||||
|
Loading…
Reference in New Issue
Block a user