fix all the test

many are off course affected by call sequence changes
This commit is contained in:
Torsten Ruger 2015-11-07 22:20:21 +02:00
parent 5ddc96718b
commit f11e8f0a13
20 changed files with 112 additions and 121 deletions

View File

@ -30,7 +30,7 @@ module Fragments
def check_return val def check_return val
check check
assert_equal Parfait::Message , @interpreter.get_register(:r1).class assert_equal Parfait::Message , @interpreter.get_register(:r0).class
assert_equal val , @interpreter.get_register(:r1).return_value assert_equal val , @interpreter.get_register(:r0).return_value
end end
end end

View File

@ -17,7 +17,7 @@ class Object
end end
end end
HERE HERE
@length = 18 @length = 15
check check
end end
end end

View File

@ -29,7 +29,7 @@ class Object
end end
end end
HERE HERE
@length = 486 @length = 483
check_return 80 check_return 80
end end
@ -46,7 +46,7 @@ class Object
end end
end end
HERE HERE
@length = 36 @length = 33
check_return 5 check_return 5
end end

View File

@ -11,7 +11,7 @@ class Object
end end
end end
HERE HERE
@length = 39 @length = 36
@stdout = "Hello Raisa, I am salama" @stdout = "Hello Raisa, I am salama"
check check
end end

View File

@ -16,7 +16,7 @@ class Object
end end
end end
HERE HERE
@length = 28 @length = 25
check_return 4 check_return 4
end end
@ -31,7 +31,7 @@ class Object
end end
end end
HERE HERE
@length = 49 @length = 46
@stdout = "10" @stdout = "10"
check check
end end
@ -53,7 +53,7 @@ class Object
end end
end end
HERE HERE
@length = 64 @length = 61
@stdout = "else" @stdout = "else"
check check
end end

View File

@ -16,7 +16,7 @@ class Object
end end
end end
HERE HERE
@length = 35 @length = 32
check check
end end
end end

View File

@ -28,7 +28,7 @@ class Object
end end
end end
HERE HERE
@length = 6598 @length = 6595
check_return 55 check_return 55
end end
end end

View File

@ -11,7 +11,7 @@ class Object
end end
end end
HERE HERE
@length = 18 @length = 15
check_return 5 check_return 5
end end
@ -27,7 +27,7 @@ class Object
end end
end end
HERE HERE
@length = 38 @length = 35
check_return 5 check_return 5
end end
@ -44,7 +44,7 @@ class Object
end end
end end
HERE HERE
@length = 42 @length = 39
check_return 5 check_return 5
end end

View File

@ -28,16 +28,16 @@ HERE
@string_input.sub!( "100" , num.to_s ) @string_input.sub!( "100" , num.to_s )
end end
def test_while_fibo def test_while_fibo100
fibo 100 fibo 100
@length = 2348 @length = 2345
#TODO bug, int max is 92 ruby converts to biginteger. #TODO bug, int max is 92 ruby converts to biginteger.
check_return 354224848179261915075 check_return 354224848179261915075
end end
def test_while_fibo def test_while_fibo92
fibo 92 fibo 92
@length = 2164 @length = 2161
check_return 7540113804746346429 check_return 7540113804746346429
end end

View File

@ -16,7 +16,7 @@ class Object
end end
end end
HERE HERE
@length = 37 @length = 34
@stdout = "" @stdout = ""
check check
end end

View File

@ -16,8 +16,8 @@ int main()
end end
end end
HERE HERE
@expect = [Label, LoadConstant,LoadConstant,OperatorInstruction,GetSlot,SetSlot, @expect = [Label, LoadConstant, LoadConstant, OperatorInstruction, GetSlot, SetSlot, Label ,
Label,RegisterTransfer,GetSlot,FunctionReturn] FunctionReturn]
check check
end end
@ -30,7 +30,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, LoadConstant,GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, LoadConstant, GetSlot, SetSlot, Label, FunctionReturn]
check check
end end
@ -42,7 +42,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, LoadConstant, GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, LoadConstant, GetSlot, SetSlot, Label, FunctionReturn]
check check
end end
@ -54,9 +54,9 @@ class Object
end end
end end
HERE HERE
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant , @expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, GetSlot , SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
GetSlot, SetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn] GetSlot, GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
check check
end end
@ -69,8 +69,8 @@ class Object
end end
end end
HERE HERE
@expect = [Label, LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,SetSlot, @expect = [Label, LoadConstant, GetSlot, SetSlot, GetSlot, GetSlot, SetSlot ,
Label,RegisterTransfer,GetSlot,FunctionReturn] Label, FunctionReturn]
was = check was = check
get = was.next(5) get = was.next(5)
assert_equal GetSlot , get.class assert_equal GetSlot , get.class
@ -86,7 +86,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, LoadConstant,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, LoadConstant, SetSlot, Label, FunctionReturn]
was = check was = check
set = was.next(2) set = was.next(2)
assert_equal SetSlot , set.class assert_equal SetSlot , set.class
@ -101,7 +101,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, LoadConstant,GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, LoadConstant, GetSlot, SetSlot, Label, FunctionReturn]
was = check was = check
set = was.next(3) set = was.next(3)
assert_equal SetSlot , set.class assert_equal SetSlot , set.class
@ -118,7 +118,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, GetSlot , SetSlot,Label , RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, GetSlot, SetSlot, Label, FunctionReturn]
was = check was = check
get = was.next(1) get = was.next(1)
assert_equal GetSlot , get.class assert_equal GetSlot , get.class

View File

@ -18,8 +18,8 @@ class Object
end end
HERE HERE
@expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant , @expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, GetSlot , SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
Label, RegisterTransfer, GetSlot, FunctionReturn] GetSlot, GetSlot, Label, FunctionReturn]
check check
end end
@ -38,8 +38,8 @@ class Object
end end
HERE HERE
@expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant , @expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, GetSlot , SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
Label, RegisterTransfer, GetSlot, FunctionReturn] GetSlot, GetSlot, Label, FunctionReturn]
check check
end end
@ -59,7 +59,7 @@ end
HERE HERE
@expect = [Label, LoadConstant, GetSlot, SetSlot, GetSlot, GetSlot, GetSlot , @expect = [Label, LoadConstant, GetSlot, SetSlot, GetSlot, GetSlot, GetSlot ,
SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot , SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot ,
RegisterTransfer, FunctionCall, Label, GetSlot, Label, RegisterTransfer, GetSlot , RegisterTransfer, FunctionCall, Label, RegisterTransfer, GetSlot, GetSlot, Label ,
FunctionReturn] FunctionReturn]
check check
end end
@ -80,7 +80,7 @@ end
HERE HERE
@expect = [Label, GetSlot, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot , @expect = [Label, GetSlot, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot ,
LoadConstant, SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label , LoadConstant, SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label ,
GetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn] RegisterTransfer, GetSlot, GetSlot, Label, FunctionReturn]
check check
end end
@ -97,7 +97,7 @@ end
HERE HERE
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant , @expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall , SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall ,
Label, GetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn] Label, RegisterTransfer, GetSlot, GetSlot, Label, FunctionReturn]
was = check was = check
set = was.next(7) set = was.next(7)
assert_equal SetSlot , set.class assert_equal SetSlot , set.class

View File

@ -17,7 +17,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, LoadConstant,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, LoadConstant,SetSlot,Label,FunctionReturn]
check check
end end
@ -34,9 +34,9 @@ class Object
end end
end end
HERE HERE
@expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant , @expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, GetSlot , SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
SetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn] GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
check check
end end
@ -49,7 +49,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, LoadConstant,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, LoadConstant,SetSlot,Label,FunctionReturn]
assert_raises{check} assert_raises{check}
end end
@ -62,7 +62,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, GetSlot,GetSlot,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, GetSlot,GetSlot,SetSlot,Label,FunctionReturn]
check check
end end
end end

View File

@ -18,7 +18,7 @@ end
HERE HERE
@expect = [Label, LoadConstant,LoadConstant, OperatorInstruction,IsPlus , @expect = [Label, LoadConstant,LoadConstant, OperatorInstruction,IsPlus ,
LoadConstant,SetSlot,Branch , Label , LoadConstant ,SetSlot, LoadConstant,SetSlot,Branch , Label , LoadConstant ,SetSlot,
Label,Label,RegisterTransfer,GetSlot,FunctionReturn] Label,Label,FunctionReturn]
check check
end end
@ -33,9 +33,8 @@ class Object
end end
end end
HERE HERE
@expect = [Label,LoadConstant,LoadConstant, OperatorInstruction,IsMinus , @expect = [Label, LoadConstant, LoadConstant, OperatorInstruction, IsMinus, Branch, Label ,
Branch ,Label , LoadConstant ,SetSlot, LoadConstant, SetSlot, Label, Label, FunctionReturn]
Label,Label , RegisterTransfer,GetSlot,FunctionReturn]
check check
end end
@ -52,7 +51,7 @@ end
HERE HERE
@expect = [Label, LoadConstant,LoadConstant,OperatorInstruction,IsZero , @expect = [Label, LoadConstant,LoadConstant,OperatorInstruction,IsZero ,
Branch , Label , LoadConstant ,SetSlot, Branch , Label , LoadConstant ,SetSlot,
Label,Label, RegisterTransfer,GetSlot,FunctionReturn] Label,Label, FunctionReturn]
check check
end end
end end

View File

@ -13,7 +13,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, LoadConstant ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, LoadConstant ,SetSlot,Label,FunctionReturn]
was = check was = check
set = was.next(2) set = was.next(2)
assert_equal SetSlot , set.class assert_equal SetSlot , set.class
@ -30,7 +30,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, GetSlot,GetSlot ,SetSlot,Label,FunctionReturn]
check check
end end
@ -44,7 +44,7 @@ class Object
end end
HERE HERE
@expect = [Label, LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,SetSlot, @expect = [Label, LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,SetSlot,
Label,RegisterTransfer,GetSlot,FunctionReturn] Label,FunctionReturn]
check check
end end
@ -57,7 +57,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, GetSlot,GetSlot ,SetSlot,Label,FunctionReturn]
check check
end end
@ -71,7 +71,7 @@ class Object
end end
end end
HERE HERE
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, GetSlot,GetSlot ,SetSlot,Label,FunctionReturn]
check check
end end
@ -83,9 +83,9 @@ class Object
end end
end end
HERE HERE
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant , @expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, GetSlot , SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
SetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn] GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
check check
end end
end end

View File

@ -16,7 +16,7 @@ class Object
end end
HERE HERE
@expect = [Label, Branch, Label, LoadConstant, SetSlot, Label, LoadConstant , @expect = [Label, Branch, Label, LoadConstant, SetSlot, Label, LoadConstant ,
IsPlus, Label, RegisterTransfer, GetSlot, FunctionReturn] IsPlus, Label, FunctionReturn]
check check
end end
@ -34,8 +34,7 @@ end
HERE HERE
@expect = [Label, LoadConstant, GetSlot, SetSlot, Branch, Label, GetSlot , @expect = [Label, LoadConstant, GetSlot, SetSlot, Branch, Label, GetSlot ,
GetSlot, LoadConstant, OperatorInstruction, GetSlot, SetSlot, Label, GetSlot , GetSlot, LoadConstant, OperatorInstruction, GetSlot, SetSlot, Label, GetSlot ,
GetSlot, IsPlus, GetSlot, GetSlot, SetSlot, Label, RegisterTransfer , GetSlot, IsPlus, GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
GetSlot, FunctionReturn]
check check
end end
@ -55,7 +54,7 @@ HERE
@expect = [Label, LoadConstant, GetSlot, SetSlot, Branch, Label, GetSlot , @expect = [Label, LoadConstant, GetSlot, SetSlot, Branch, Label, GetSlot ,
GetSlot, LoadConstant, OperatorInstruction, GetSlot, SetSlot, GetSlot, GetSlot , GetSlot, LoadConstant, OperatorInstruction, GetSlot, SetSlot, GetSlot, GetSlot ,
SetSlot, Label, GetSlot, GetSlot, LoadConstant, OperatorInstruction, IsPlus , SetSlot, Label, GetSlot, GetSlot, LoadConstant, OperatorInstruction, IsPlus ,
Label, RegisterTransfer, GetSlot, FunctionReturn] Label, FunctionReturn]
check check
end end
end end

View File

@ -30,12 +30,12 @@ class AddTest < MiniTest::Test
assert Integer , @interpreter.get_register( :r2 ).class assert Integer , @interpreter.get_register( :r2 ).class
end end
def test_transfer def test_transfer
transfer = ticks 8 transfer = ticks 16
assert_equal Register::RegisterTransfer , transfer.class assert_equal Register::RegisterTransfer , transfer.class
assert_equal @interpreter.get_register(transfer.to) , @interpreter.get_register(transfer.from) assert_equal @interpreter.get_register(transfer.to) , @interpreter.get_register(transfer.from)
end end
def test_call def test_call
ret = ticks(18) ret = ticks(15)
assert_equal Register::FunctionReturn , ret.class assert_equal Register::FunctionReturn , ret.class
object = @interpreter.get_register( ret.register ) object = @interpreter.get_register( ret.register )
@ -44,7 +44,7 @@ class AddTest < MiniTest::Test
assert_equal Register::Label , link.class assert_equal Register::Label , link.class
end end
def test_adding def test_adding
done_op = ticks(13) done_op = ticks(12)
assert_equal Register::OperatorInstruction , done_op.class assert_equal Register::OperatorInstruction , done_op.class
left = @interpreter.get_register(done_op.left) left = @interpreter.get_register(done_op.left)
rr = done_op.right rr = done_op.right
@ -53,7 +53,7 @@ class AddTest < MiniTest::Test
assert_equal Fixnum , right.class assert_equal Fixnum , right.class
assert_equal 7 , right assert_equal 7 , right
assert_equal 12 , left assert_equal 12 , left
done_tr = ticks(3) done_tr = ticks(4)
assert_equal Register::RegisterTransfer , done_tr.class assert_equal Register::RegisterTransfer , done_tr.class
result = @interpreter.get_register(done_op.left) result = @interpreter.get_register(done_op.left)
assert_equal result , 12 assert_equal result , 12
@ -62,10 +62,9 @@ class AddTest < MiniTest::Test
def test_chain def test_chain
#show_ticks # get output of what is #show_ticks # get output of what is
["Branch","Label","LoadConstant","GetSlot","SetSlot", ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label", "LoadConstant","SetSlot","FunctionCall","Label","LoadConstant",
"LoadConstant","LoadConstant","OperatorInstruction","SetSlot","Label", "LoadConstant","OperatorInstruction","SetSlot","Label","FunctionReturn",
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall", "RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index|
"NilClass"].each_with_index do |name , index|
got = ticks(1) got = ticks(1)
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

View File

@ -30,18 +30,18 @@ HERE
@interpreter.start Register.machine.init @interpreter.start Register.machine.init
#show_ticks # get output of what is #show_ticks # get output of what is
["Branch","Label","LoadConstant","GetSlot","SetSlot", ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label", "LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
"GetSlot","GetSlot","SetSlot","LoadConstant","SetSlot", "GetSlot","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot",
"RegisterTransfer","FunctionCall","Label","GetSlot","LoadConstant",
"OperatorInstruction","IsZero","GetSlot","LoadConstant","SetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant", "LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","RegisterTransfer","FunctionCall","Label","GetSlot", "SetSlot","RegisterTransfer","FunctionCall","Label","GetSlot",
"LoadConstant","OperatorInstruction","IsZero","GetSlot","LoadConstant", "RegisterTransfer","Syscall","RegisterTransfer","RegisterTransfer","SetSlot",
"SetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot", "Label","FunctionReturn","RegisterTransfer","GetSlot","GetSlot",
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label", "Branch","Label","Label","FunctionReturn","RegisterTransfer",
"GetSlot","RegisterTransfer","Syscall","RegisterTransfer","RegisterTransfer", "GetSlot","GetSlot","Label","FunctionReturn","RegisterTransfer",
"SetSlot","Label","RegisterTransfer","GetSlot","FunctionReturn", "Syscall","NilClass"].each_with_index do |name , index|
"GetSlot","Branch","Label","Label","RegisterTransfer",
"GetSlot","FunctionReturn","GetSlot","Label","RegisterTransfer",
"GetSlot","FunctionReturn","RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index|
got = ticks(1) got = ticks(1)
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

View File

@ -57,33 +57,32 @@ HERE
@interpreter.start Register.machine.init @interpreter.start Register.machine.init
#show_ticks # get output of what is #show_ticks # get output of what is
["Branch","Label","LoadConstant","GetSlot","SetSlot", ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label", "LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
"GetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot", "LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer", "SetSlot","LoadConstant","SetSlot","RegisterTransfer","FunctionCall",
"FunctionCall","Label","LoadConstant","GetSlot","SetSlot", "Label","LoadConstant","GetSlot","SetSlot","GetSlot",
"GetSlot","GetSlot","SetSlot","LoadConstant","SetSlot", "GetSlot","SetSlot","LoadConstant","SetSlot","LoadConstant",
"LoadConstant","SetSlot","GetSlot","GetSlot","SetSlot", "SetSlot","GetSlot","GetSlot","SetSlot","LoadConstant",
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label", "SetSlot","RegisterTransfer","FunctionCall","Label","GetSlot",
"GetSlot","LoadConstant","OperatorInstruction","GetSlot","SetSlot", "LoadConstant","OperatorInstruction","GetSlot","SetSlot","GetSlot",
"GetSlot","GetSlot","GetSlot","OperatorInstruction","GetSlot", "GetSlot","GetSlot","OperatorInstruction","GetSlot","SetSlot",
"SetSlot","GetSlot","GetSlot","IsNotzero","Label", "GetSlot","GetSlot","IsNotzero","Label","GetSlot",
"GetSlot","GetSlot","SetSlot","LoadConstant","SetSlot", "GetSlot","SetSlot","LoadConstant","SetSlot","LoadConstant",
"LoadConstant","SetSlot","GetSlot","GetSlot","SetSlot", "SetSlot","GetSlot","GetSlot","SetSlot","LoadConstant",
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label", "SetSlot","RegisterTransfer","FunctionCall","Label","GetSlot",
"GetSlot","LoadConstant","OperatorInstruction","IsZero","Branch", "LoadConstant","OperatorInstruction","IsZero","Branch","Label",
"GetSlot","LoadConstant","OperatorInstruction","IsZero","Label",
"LoadConstant","SetSlot","Label","GetSlot","LoadConstant",
"OperatorInstruction","IsZero","Label","LoadConstant","SetSlot",
"Label","GetSlot","LoadConstant","OperatorInstruction","IsZero", "Label","GetSlot","LoadConstant","OperatorInstruction","IsZero",
"Label","LoadConstant","SetSlot","Label","GetSlot", "Label","LoadConstant","SetSlot","Label","GetSlot",
"LoadConstant","OperatorInstruction","IsZero","Label","LoadConstant", "LoadConstant","OperatorInstruction","IsZero","Label","LoadConstant",
"SetSlot","Label","GetSlot","LoadConstant","OperatorInstruction", "SetSlot","Label","Label","FunctionReturn","RegisterTransfer",
"IsZero","Label","LoadConstant","SetSlot","Label", "GetSlot","GetSlot","GetSlot","SetSlot","Label",
"GetSlot","LoadConstant","OperatorInstruction","IsZero","Label", "GetSlot","SetSlot","Label","FunctionReturn","RegisterTransfer",
"LoadConstant","SetSlot","Label","Label","RegisterTransfer", "GetSlot","GetSlot","SetSlot","Label","FunctionReturn",
"GetSlot","FunctionReturn","GetSlot","GetSlot","SetSlot", "RegisterTransfer","GetSlot","GetSlot","Label","FunctionReturn",
"Label","GetSlot","SetSlot","Label","RegisterTransfer", "RegisterTransfer","Syscall"].each_with_index do |name , index|
"GetSlot","FunctionReturn","GetSlot","SetSlot","Label",
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","Label",
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall",
"NilClass"].each_with_index do |name , index|
got = ticks(1) got = ticks(1)
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

View File

@ -38,27 +38,22 @@ class TestPuts < MiniTest::Test
def test_get def test_get
assert_equal Register::GetSlot , ticks(4).class assert_equal Register::GetSlot , ticks(4).class
assert @interpreter.get_register( :r1 ) assert @interpreter.get_register( :r1 )
assert Integer , @interpreter.get_register( :r1 ).class assert Integer , @interpreter.get_register( :r1 ).class
end
def test_transfer
transfer = ticks 8
assert_equal Register::RegisterTransfer , transfer.class
assert_equal @interpreter.get_register(transfer.to) , @interpreter.get_register(transfer.from)
end end
def test_call def test_call
assert_equal Register::FunctionCall , ticks(9).class assert_equal Register::FunctionCall , ticks(8).class
end end
def test_chain def test_chain
#show_ticks # get output of what is #show_ticks # get output of what is
["Branch","Label","LoadConstant","GetSlot","SetSlot", ["Branch","Label","LoadConstant","GetSlot","SetSlot",
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label", "LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
"GetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot", "LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer", "SetSlot","LoadConstant","SetSlot","RegisterTransfer","FunctionCall",
"FunctionCall","Label","GetSlot","RegisterTransfer","Syscall", "Label","GetSlot","RegisterTransfer","Syscall","RegisterTransfer",
"RegisterTransfer","RegisterTransfer","SetSlot","Label","RegisterTransfer", "RegisterTransfer","SetSlot","Label","FunctionReturn","RegisterTransfer",
"GetSlot","FunctionReturn","GetSlot","Label","RegisterTransfer", "GetSlot","GetSlot","Label","FunctionReturn","RegisterTransfer",
"GetSlot","FunctionReturn","RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index| "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}"
@ -66,20 +61,20 @@ class TestPuts < MiniTest::Test
end end
def test_putstring def test_putstring
done = ticks(25) done = ticks(24)
assert_equal Register::Syscall , done.class assert_equal Register::Syscall , done.class
assert_equal "Hello again" , @interpreter.stdout assert_equal "Hello again" , @interpreter.stdout
end end
def test_return def test_return
done = ticks(32) done = ticks(29)
assert_equal Register::FunctionReturn , done.class assert_equal Register::FunctionReturn , done.class
assert Register::Label , @interpreter.instruction.class assert Register::Label , @interpreter.instruction.class
assert @interpreter.instruction.is_a?(Register::Instruction) , "not instruction #{@interpreter.instruction}" assert @interpreter.instruction.is_a?(Register::Instruction) , "not instruction #{@interpreter.instruction}"
end end
def test_exit def test_exit
done = ticks(40) done = ticks(42)
assert_equal NilClass , done.class assert_equal NilClass , done.class
assert_equal "Hello again" , @interpreter.stdout assert_equal "Hello again" , @interpreter.stdout
end end