fix all the test
many are off course affected by call sequence changes
This commit is contained in:
parent
5ddc96718b
commit
f11e8f0a13
@ -30,7 +30,7 @@ module Fragments
|
||||
|
||||
def check_return val
|
||||
check
|
||||
assert_equal Parfait::Message , @interpreter.get_register(:r1).class
|
||||
assert_equal val , @interpreter.get_register(:r1).return_value
|
||||
assert_equal Parfait::Message , @interpreter.get_register(:r0).class
|
||||
assert_equal val , @interpreter.get_register(:r0).return_value
|
||||
end
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 18
|
||||
@length = 15
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -29,7 +29,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 486
|
||||
@length = 483
|
||||
check_return 80
|
||||
end
|
||||
|
||||
@ -46,7 +46,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 36
|
||||
@length = 33
|
||||
check_return 5
|
||||
end
|
||||
|
||||
|
@ -11,7 +11,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 39
|
||||
@length = 36
|
||||
@stdout = "Hello Raisa, I am salama"
|
||||
check
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 28
|
||||
@length = 25
|
||||
check_return 4
|
||||
end
|
||||
|
||||
@ -31,7 +31,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 49
|
||||
@length = 46
|
||||
@stdout = "10"
|
||||
check
|
||||
end
|
||||
@ -53,7 +53,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 64
|
||||
@length = 61
|
||||
@stdout = "else"
|
||||
check
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 35
|
||||
@length = 32
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 6598
|
||||
@length = 6595
|
||||
check_return 55
|
||||
end
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 18
|
||||
@length = 15
|
||||
check_return 5
|
||||
end
|
||||
|
||||
@ -27,7 +27,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 38
|
||||
@length = 35
|
||||
check_return 5
|
||||
end
|
||||
|
||||
@ -44,7 +44,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 42
|
||||
@length = 39
|
||||
check_return 5
|
||||
end
|
||||
|
||||
|
@ -28,16 +28,16 @@ HERE
|
||||
@string_input.sub!( "100" , num.to_s )
|
||||
end
|
||||
|
||||
def test_while_fibo
|
||||
def test_while_fibo100
|
||||
fibo 100
|
||||
@length = 2348
|
||||
#TODO bug, int max is 92 ruby converts to biginteger.
|
||||
@length = 2345
|
||||
#TODO bug, int max is 92 ruby converts to biginteger.
|
||||
check_return 354224848179261915075
|
||||
end
|
||||
|
||||
def test_while_fibo
|
||||
def test_while_fibo92
|
||||
fibo 92
|
||||
@length = 2164
|
||||
@length = 2161
|
||||
check_return 7540113804746346429
|
||||
end
|
||||
|
||||
|
@ -16,7 +16,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@length = 37
|
||||
@length = 34
|
||||
@stdout = ""
|
||||
check
|
||||
end
|
||||
|
@ -16,8 +16,8 @@ int main()
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant,LoadConstant,OperatorInstruction,GetSlot,SetSlot,
|
||||
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, LoadConstant, LoadConstant, OperatorInstruction, GetSlot, SetSlot, Label ,
|
||||
FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -30,7 +30,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant,GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, LoadConstant, GetSlot, SetSlot, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -42,7 +42,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant, GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, LoadConstant, GetSlot, SetSlot, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -54,9 +54,9 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
|
||||
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, GetSlot ,
|
||||
GetSlot, SetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn]
|
||||
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
|
||||
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
|
||||
GetSlot, GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -69,8 +69,8 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,SetSlot,
|
||||
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, LoadConstant, GetSlot, SetSlot, GetSlot, GetSlot, SetSlot ,
|
||||
Label, FunctionReturn]
|
||||
was = check
|
||||
get = was.next(5)
|
||||
assert_equal GetSlot , get.class
|
||||
@ -86,7 +86,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, LoadConstant, SetSlot, Label, FunctionReturn]
|
||||
was = check
|
||||
set = was.next(2)
|
||||
assert_equal SetSlot , set.class
|
||||
@ -101,7 +101,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant,GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, LoadConstant, GetSlot, SetSlot, Label, FunctionReturn]
|
||||
was = check
|
||||
set = was.next(3)
|
||||
assert_equal SetSlot , set.class
|
||||
@ -118,7 +118,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, GetSlot , SetSlot,Label , RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, GetSlot, SetSlot, Label, FunctionReturn]
|
||||
was = check
|
||||
get = was.next(1)
|
||||
assert_equal GetSlot , get.class
|
||||
|
@ -18,8 +18,8 @@ class Object
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
|
||||
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, GetSlot ,
|
||||
Label, RegisterTransfer, GetSlot, FunctionReturn]
|
||||
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
|
||||
GetSlot, GetSlot, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -38,8 +38,8 @@ class Object
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
|
||||
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, GetSlot ,
|
||||
Label, RegisterTransfer, GetSlot, FunctionReturn]
|
||||
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
|
||||
GetSlot, GetSlot, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -59,7 +59,7 @@ end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant, GetSlot, SetSlot, GetSlot, GetSlot, GetSlot ,
|
||||
SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot ,
|
||||
RegisterTransfer, FunctionCall, Label, GetSlot, Label, RegisterTransfer, GetSlot ,
|
||||
RegisterTransfer, FunctionCall, Label, RegisterTransfer, GetSlot, GetSlot, Label ,
|
||||
FunctionReturn]
|
||||
check
|
||||
end
|
||||
@ -80,7 +80,7 @@ end
|
||||
HERE
|
||||
@expect = [Label, GetSlot, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot ,
|
||||
LoadConstant, SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label ,
|
||||
GetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn]
|
||||
RegisterTransfer, GetSlot, GetSlot, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -97,7 +97,7 @@ end
|
||||
HERE
|
||||
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
|
||||
SetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall ,
|
||||
Label, GetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn]
|
||||
Label, RegisterTransfer, GetSlot, GetSlot, Label, FunctionReturn]
|
||||
was = check
|
||||
set = was.next(7)
|
||||
assert_equal SetSlot , set.class
|
||||
|
@ -17,7 +17,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, LoadConstant,SetSlot,Label,FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -34,9 +34,9 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
|
||||
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, GetSlot ,
|
||||
SetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn]
|
||||
@expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
|
||||
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
|
||||
GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -49,7 +49,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, LoadConstant,SetSlot,Label,FunctionReturn]
|
||||
assert_raises{check}
|
||||
end
|
||||
|
||||
@ -62,7 +62,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, GetSlot,GetSlot,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, GetSlot,GetSlot,SetSlot,Label,FunctionReturn]
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -18,7 +18,7 @@ end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant,LoadConstant, OperatorInstruction,IsPlus ,
|
||||
LoadConstant,SetSlot,Branch , Label , LoadConstant ,SetSlot,
|
||||
Label,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
Label,Label,FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -33,9 +33,8 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label,LoadConstant,LoadConstant, OperatorInstruction,IsMinus ,
|
||||
Branch ,Label , LoadConstant ,SetSlot,
|
||||
Label,Label , RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, LoadConstant, LoadConstant, OperatorInstruction, IsMinus, Branch, Label ,
|
||||
LoadConstant, SetSlot, Label, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -52,7 +51,7 @@ end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant,LoadConstant,OperatorInstruction,IsZero ,
|
||||
Branch , Label , LoadConstant ,SetSlot,
|
||||
Label,Label, RegisterTransfer,GetSlot,FunctionReturn]
|
||||
Label,Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, LoadConstant ,SetSlot,Label,FunctionReturn]
|
||||
was = check
|
||||
set = was.next(2)
|
||||
assert_equal SetSlot , set.class
|
||||
@ -30,7 +30,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -44,7 +44,7 @@ class Object
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,SetSlot,
|
||||
Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
Label,FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -57,7 +57,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -71,7 +71,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
||||
@expect = [Label, GetSlot,GetSlot ,SetSlot,Label,FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -83,9 +83,9 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
|
||||
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, GetSlot ,
|
||||
SetSlot, Label, RegisterTransfer, GetSlot, FunctionReturn]
|
||||
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
|
||||
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
|
||||
GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ class Object
|
||||
end
|
||||
HERE
|
||||
@expect = [Label, Branch, Label, LoadConstant, SetSlot, Label, LoadConstant ,
|
||||
IsPlus, Label, RegisterTransfer, GetSlot, FunctionReturn]
|
||||
IsPlus, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -34,8 +34,7 @@ end
|
||||
HERE
|
||||
@expect = [Label, LoadConstant, GetSlot, SetSlot, Branch, Label, GetSlot ,
|
||||
GetSlot, LoadConstant, OperatorInstruction, GetSlot, SetSlot, Label, GetSlot ,
|
||||
GetSlot, IsPlus, GetSlot, GetSlot, SetSlot, Label, RegisterTransfer ,
|
||||
GetSlot, FunctionReturn]
|
||||
GetSlot, IsPlus, GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
|
||||
@ -55,7 +54,7 @@ HERE
|
||||
@expect = [Label, LoadConstant, GetSlot, SetSlot, Branch, Label, GetSlot ,
|
||||
GetSlot, LoadConstant, OperatorInstruction, GetSlot, SetSlot, GetSlot, GetSlot ,
|
||||
SetSlot, Label, GetSlot, GetSlot, LoadConstant, OperatorInstruction, IsPlus ,
|
||||
Label, RegisterTransfer, GetSlot, FunctionReturn]
|
||||
Label, FunctionReturn]
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -30,12 +30,12 @@ class AddTest < MiniTest::Test
|
||||
assert Integer , @interpreter.get_register( :r2 ).class
|
||||
end
|
||||
def test_transfer
|
||||
transfer = ticks 8
|
||||
transfer = ticks 16
|
||||
assert_equal Register::RegisterTransfer , transfer.class
|
||||
assert_equal @interpreter.get_register(transfer.to) , @interpreter.get_register(transfer.from)
|
||||
end
|
||||
def test_call
|
||||
ret = ticks(18)
|
||||
ret = ticks(15)
|
||||
assert_equal Register::FunctionReturn , ret.class
|
||||
|
||||
object = @interpreter.get_register( ret.register )
|
||||
@ -44,7 +44,7 @@ class AddTest < MiniTest::Test
|
||||
assert_equal Register::Label , link.class
|
||||
end
|
||||
def test_adding
|
||||
done_op = ticks(13)
|
||||
done_op = ticks(12)
|
||||
assert_equal Register::OperatorInstruction , done_op.class
|
||||
left = @interpreter.get_register(done_op.left)
|
||||
rr = done_op.right
|
||||
@ -53,7 +53,7 @@ class AddTest < MiniTest::Test
|
||||
assert_equal Fixnum , right.class
|
||||
assert_equal 7 , right
|
||||
assert_equal 12 , left
|
||||
done_tr = ticks(3)
|
||||
done_tr = ticks(4)
|
||||
assert_equal Register::RegisterTransfer , done_tr.class
|
||||
result = @interpreter.get_register(done_op.left)
|
||||
assert_equal result , 12
|
||||
@ -62,10 +62,9 @@ class AddTest < MiniTest::Test
|
||||
def test_chain
|
||||
#show_ticks # get output of what is
|
||||
["Branch","Label","LoadConstant","GetSlot","SetSlot",
|
||||
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label",
|
||||
"LoadConstant","LoadConstant","OperatorInstruction","SetSlot","Label",
|
||||
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall",
|
||||
"NilClass"].each_with_index do |name , index|
|
||||
"LoadConstant","SetSlot","FunctionCall","Label","LoadConstant",
|
||||
"LoadConstant","OperatorInstruction","SetSlot","Label","FunctionReturn",
|
||||
"RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index|
|
||||
got = ticks(1)
|
||||
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
||||
end
|
||||
|
@ -30,18 +30,18 @@ HERE
|
||||
@interpreter.start Register.machine.init
|
||||
#show_ticks # get output of what is
|
||||
["Branch","Label","LoadConstant","GetSlot","SetSlot",
|
||||
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label",
|
||||
"GetSlot","GetSlot","SetSlot","LoadConstant","SetSlot",
|
||||
"LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
|
||||
"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",
|
||||
"SetSlot","RegisterTransfer","FunctionCall","Label","GetSlot",
|
||||
"LoadConstant","OperatorInstruction","IsZero","GetSlot","LoadConstant",
|
||||
"SetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot",
|
||||
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label",
|
||||
"GetSlot","RegisterTransfer","Syscall","RegisterTransfer","RegisterTransfer",
|
||||
"SetSlot","Label","RegisterTransfer","GetSlot","FunctionReturn",
|
||||
"GetSlot","Branch","Label","Label","RegisterTransfer",
|
||||
"GetSlot","FunctionReturn","GetSlot","Label","RegisterTransfer",
|
||||
"GetSlot","FunctionReturn","RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index|
|
||||
"RegisterTransfer","Syscall","RegisterTransfer","RegisterTransfer","SetSlot",
|
||||
"Label","FunctionReturn","RegisterTransfer","GetSlot","GetSlot",
|
||||
"Branch","Label","Label","FunctionReturn","RegisterTransfer",
|
||||
"GetSlot","GetSlot","Label","FunctionReturn","RegisterTransfer",
|
||||
"Syscall","NilClass"].each_with_index do |name , index|
|
||||
got = ticks(1)
|
||||
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
||||
end
|
||||
|
@ -57,33 +57,32 @@ HERE
|
||||
@interpreter.start Register.machine.init
|
||||
#show_ticks # get output of what is
|
||||
["Branch","Label","LoadConstant","GetSlot","SetSlot",
|
||||
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label",
|
||||
"GetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot",
|
||||
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer",
|
||||
"FunctionCall","Label","LoadConstant","GetSlot","SetSlot",
|
||||
"GetSlot","GetSlot","SetSlot","LoadConstant","SetSlot",
|
||||
"LoadConstant","SetSlot","GetSlot","GetSlot","SetSlot",
|
||||
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label",
|
||||
"GetSlot","LoadConstant","OperatorInstruction","GetSlot","SetSlot",
|
||||
"GetSlot","GetSlot","GetSlot","OperatorInstruction","GetSlot",
|
||||
"SetSlot","GetSlot","GetSlot","IsNotzero","Label",
|
||||
"GetSlot","GetSlot","SetSlot","LoadConstant","SetSlot",
|
||||
"LoadConstant","SetSlot","GetSlot","GetSlot","SetSlot",
|
||||
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label",
|
||||
"GetSlot","LoadConstant","OperatorInstruction","IsZero","Branch",
|
||||
"LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
|
||||
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
|
||||
"SetSlot","LoadConstant","SetSlot","RegisterTransfer","FunctionCall",
|
||||
"Label","LoadConstant","GetSlot","SetSlot","GetSlot",
|
||||
"GetSlot","SetSlot","LoadConstant","SetSlot","LoadConstant",
|
||||
"SetSlot","GetSlot","GetSlot","SetSlot","LoadConstant",
|
||||
"SetSlot","RegisterTransfer","FunctionCall","Label","GetSlot",
|
||||
"LoadConstant","OperatorInstruction","GetSlot","SetSlot","GetSlot",
|
||||
"GetSlot","GetSlot","OperatorInstruction","GetSlot","SetSlot",
|
||||
"GetSlot","GetSlot","IsNotzero","Label","GetSlot",
|
||||
"GetSlot","SetSlot","LoadConstant","SetSlot","LoadConstant",
|
||||
"SetSlot","GetSlot","GetSlot","SetSlot","LoadConstant",
|
||||
"SetSlot","RegisterTransfer","FunctionCall","Label","GetSlot",
|
||||
"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","LoadConstant","SetSlot","Label","GetSlot",
|
||||
"LoadConstant","OperatorInstruction","IsZero","Label","LoadConstant",
|
||||
"SetSlot","Label","GetSlot","LoadConstant","OperatorInstruction",
|
||||
"IsZero","Label","LoadConstant","SetSlot","Label",
|
||||
"GetSlot","LoadConstant","OperatorInstruction","IsZero","Label",
|
||||
"LoadConstant","SetSlot","Label","Label","RegisterTransfer",
|
||||
"GetSlot","FunctionReturn","GetSlot","GetSlot","SetSlot",
|
||||
"Label","GetSlot","SetSlot","Label","RegisterTransfer",
|
||||
"GetSlot","FunctionReturn","GetSlot","SetSlot","Label",
|
||||
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","Label",
|
||||
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall",
|
||||
"NilClass"].each_with_index do |name , index|
|
||||
"SetSlot","Label","Label","FunctionReturn","RegisterTransfer",
|
||||
"GetSlot","GetSlot","GetSlot","SetSlot","Label",
|
||||
"GetSlot","SetSlot","Label","FunctionReturn","RegisterTransfer",
|
||||
"GetSlot","GetSlot","SetSlot","Label","FunctionReturn",
|
||||
"RegisterTransfer","GetSlot","GetSlot","Label","FunctionReturn",
|
||||
"RegisterTransfer","Syscall"].each_with_index do |name , index|
|
||||
got = ticks(1)
|
||||
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
||||
end
|
||||
|
@ -38,27 +38,22 @@ class TestPuts < MiniTest::Test
|
||||
def test_get
|
||||
assert_equal Register::GetSlot , ticks(4).class
|
||||
assert @interpreter.get_register( :r1 )
|
||||
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)
|
||||
assert Integer , @interpreter.get_register( :r1 ).class
|
||||
end
|
||||
def test_call
|
||||
assert_equal Register::FunctionCall , ticks(9).class
|
||||
assert_equal Register::FunctionCall , ticks(8).class
|
||||
end
|
||||
|
||||
def test_chain
|
||||
#show_ticks # get output of what is
|
||||
["Branch","Label","LoadConstant","GetSlot","SetSlot",
|
||||
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","Label",
|
||||
"GetSlot","LoadConstant","SetSlot","LoadConstant","SetSlot",
|
||||
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer",
|
||||
"FunctionCall","Label","GetSlot","RegisterTransfer","Syscall",
|
||||
"RegisterTransfer","RegisterTransfer","SetSlot","Label","RegisterTransfer",
|
||||
"GetSlot","FunctionReturn","GetSlot","Label","RegisterTransfer",
|
||||
"GetSlot","FunctionReturn","RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index|
|
||||
"LoadConstant","SetSlot","FunctionCall","Label","GetSlot",
|
||||
"LoadConstant","SetSlot","LoadConstant","SetSlot","LoadConstant",
|
||||
"SetSlot","LoadConstant","SetSlot","RegisterTransfer","FunctionCall",
|
||||
"Label","GetSlot","RegisterTransfer","Syscall","RegisterTransfer",
|
||||
"RegisterTransfer","SetSlot","Label","FunctionReturn","RegisterTransfer",
|
||||
"GetSlot","GetSlot","Label","FunctionReturn","RegisterTransfer",
|
||||
"Syscall","NilClass"].each_with_index do |name , index|
|
||||
got = ticks(1)
|
||||
#puts "TICK #{index}"
|
||||
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
|
||||
@ -66,20 +61,20 @@ class TestPuts < MiniTest::Test
|
||||
end
|
||||
|
||||
def test_putstring
|
||||
done = ticks(25)
|
||||
done = ticks(24)
|
||||
assert_equal Register::Syscall , done.class
|
||||
assert_equal "Hello again" , @interpreter.stdout
|
||||
end
|
||||
|
||||
def test_return
|
||||
done = ticks(32)
|
||||
done = ticks(29)
|
||||
assert_equal Register::FunctionReturn , done.class
|
||||
assert Register::Label , @interpreter.instruction.class
|
||||
assert @interpreter.instruction.is_a?(Register::Instruction) , "not instruction #{@interpreter.instruction}"
|
||||
end
|
||||
|
||||
def test_exit
|
||||
done = ticks(40)
|
||||
done = ticks(42)
|
||||
assert_equal NilClass , done.class
|
||||
assert_equal "Hello again" , @interpreter.stdout
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user