removed blocks and moved to labels

somewhat easier to understand the code as a linked list
relatively painless change, considering
This commit is contained in:
Torsten Ruger
2015-10-23 21:27:36 +03:00
parent f1f56f0d4e
commit 57f37ec023
22 changed files with 281 additions and 370 deletions

View File

@ -16,7 +16,7 @@ class Object
end
end
HERE
@length = 22
@length = 26
check
end
@ -31,7 +31,7 @@ class Object
end
end
HERE
@length = 38
@length = 45
@stdout = "10"
check
end
@ -53,7 +53,7 @@ class Object
end
end
HERE
@length = 49
@length = 57
@stdout = "else"
check
end

View File

@ -9,16 +9,20 @@ module Statements
machine.parse_and_compile @string_input
produced = Register.machine.space.get_main.source
assert @expect , "No output given"
assert_equal @expect.length , produced.blocks.length , "Block length"
produced.blocks.each_with_index do |b,i|
codes = @expect[i]
assert codes , "No codes for block #{i}"
assert_equal b.codes.length , codes.length , "Code length for block #{i+1}"
b.codes.each_with_index do |c , ii |
assert_equal codes[ii] , c.class , "Block #{i+1} , code #{ii+1}"
end
end
produced.blocks
#assert_equal @expect.length , produced.instructions.length , "instructions length #{produced.instructions.to_ac}"
compare_instructions produced.instructions , @expect
produced.instructions
end
def compare_instructions instruction , expect
index = 0
begin
should = expect[index]
assert should , "No instruction at #{index}"
assert_equal instruction.class , should , "Expected at #{index+1}"
index += 1
instruction = instruction.next
end while( instruction )
end

View File

@ -16,8 +16,8 @@ int main()
end
end
HERE
@expect = [[SaveReturn,LoadConstant,LoadConstant,
OperatorInstruction,GetSlot,SetSlot],[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,LoadConstant,OperatorInstruction,GetSlot,SetSlot,
Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -30,7 +30,7 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot] , [RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -42,7 +42,7 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant, GetSlot,SetSlot] , [RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant, GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -54,8 +54,9 @@ class Object
end
end
HERE
@expect = [[SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant,SetSlot,
RegisterTransfer,FunctionCall,GetSlot,GetSlot,SetSlot] , [RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant,SetSlot,
RegisterTransfer,FunctionCall,GetSlot,GetSlot,SetSlot ,
Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -68,10 +69,10 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot] ,
[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,
Label,RegisterTransfer,GetSlot,FunctionReturn]
was = check
get = was[0].codes[5]
get = was.next(6)
assert_equal GetSlot , get.class
assert_equal 3, get.index , "Get to frame index must be offset, not #{get.index}"
end
@ -85,9 +86,9 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant,SetSlot] , [RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
was = check
set = was[0].codes[2]
set = was.next(3)
assert_equal SetSlot , set.class
assert_equal 9, set.index , "Set to args index must be offset, not #{set.index}"
end
@ -100,9 +101,9 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot] , [RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
was = check
set = was[0].codes[3]
set = was.next(4)
assert_equal SetSlot , set.class
assert_equal 3, set.index , "Set to frame index must be offset, not #{set.index}"
end
@ -117,10 +118,9 @@ class Object
end
end
HERE
@expect = [[SaveReturn,GetSlot] ,
[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,GetSlot , Label , RegisterTransfer,GetSlot,FunctionReturn]
was = check
get = was[0].codes[1]
get = was.next(2)
assert_equal GetSlot , get.class
assert_equal 9, get.index , "Get to frame index must be offset, not #{get.index}"
end

View File

@ -17,9 +17,9 @@ class Object
end
end
HERE
@expect = [[SaveReturn,GetSlot,LoadConstant,
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot] ,
[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,GetSlot,LoadConstant,
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,
Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -37,9 +37,9 @@ class Object
end
end
HERE
@expect = [[SaveReturn,GetSlot,LoadConstant,
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot] ,
[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,GetSlot,LoadConstant,
SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,GetSlot ,
Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -57,9 +57,9 @@ class Object
end
end
HERE
@expect = [ [SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot,
@expect = [ Label, SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot,
GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,RegisterTransfer,FunctionCall,
GetSlot] ,[RegisterTransfer,GetSlot,FunctionReturn] ]
GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -77,9 +77,9 @@ class Object
end
end
HERE
@expect = [ [SaveReturn,GetSlot,GetSlot,GetSlot,SetSlot,
@expect = [ Label, SaveReturn,GetSlot,GetSlot,GetSlot,SetSlot,
LoadConstant,SetSlot,RegisterTransfer,FunctionCall,
GetSlot] ,[RegisterTransfer,GetSlot,FunctionReturn] ]
GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -94,11 +94,11 @@ int main()
end
end
HERE
@expect = [ [SaveReturn , GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,LoadConstant,
SetSlot,RegisterTransfer,FunctionCall,GetSlot],
[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [ Label, SaveReturn , GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,LoadConstant,
SetSlot,RegisterTransfer,FunctionCall,GetSlot,
Label,RegisterTransfer,GetSlot,FunctionReturn]
was = check
set = was[0].codes[7]
set = was.next(8)
assert_equal SetSlot , set.class
assert_equal 9, set.index , "Set to message must be offset, not #{set.index}"
end

View File

@ -16,10 +16,9 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant,LoadConstant,
OperatorInstruction,IsPlus] ,
[LoadConstant,Branch] ,[LoadConstant] ,[] ,
[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,LoadConstant, OperatorInstruction,IsPlus ,
LoadConstant,Branch , Label , LoadConstant ,
Label,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -34,10 +33,9 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant,LoadConstant,
OperatorInstruction,IsMinus] ,
[Branch] ,[LoadConstant] ,[] ,
[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,LoadConstant, OperatorInstruction,IsMinus ,
Branch ,Label , LoadConstant ,
Label,Label , RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -52,10 +50,9 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant,LoadConstant,
OperatorInstruction,IsZero] ,
[Branch] ,[LoadConstant] ,[] ,
[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,LoadConstant,OperatorInstruction,IsZero ,
Branch , Label , LoadConstant ,
Label,Label, RegisterTransfer,GetSlot,FunctionReturn]
check
end
end

View File

@ -13,7 +13,7 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant] , [RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant ,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -26,7 +26,7 @@ class Object
end
end
HERE
@expect = [[SaveReturn,GetSlot,GetSlot] , [RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,GetSlot,GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -39,8 +39,8 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot] ,
[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot,GetSlot,GetSlot ,
Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -53,7 +53,7 @@ class Object
end
end
HERE
@expect = [[SaveReturn,GetSlot,GetSlot] , [RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,GetSlot,GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -65,8 +65,8 @@ class Object
end
end
HERE
@expect = [[SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant,
SetSlot,RegisterTransfer,FunctionCall,GetSlot] , [RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,GetSlot,GetSlot,SetSlot, LoadConstant,
SetSlot,RegisterTransfer,FunctionCall,GetSlot ,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
end

View File

@ -15,8 +15,8 @@ class Object
end
end
HERE
@expect = [[SaveReturn],[LoadConstant,IsPlus,LoadConstant,Branch],
[],[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,Label,LoadConstant,IsPlus,LoadConstant,Branch,
Label,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -28,12 +28,13 @@ class Object
while_plus(n)
n = n - 1
end
return n
end
end
HERE
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot],[GetSlot,GetSlot, IsPlus,GetSlot,
GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,Branch],
[],[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot,Label,GetSlot,GetSlot, IsPlus,GetSlot,
GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,Branch,
Label,GetSlot,GetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
@ -50,11 +51,11 @@ class Object
end
end
HERE
@expect = [[SaveReturn,LoadConstant,GetSlot,SetSlot],
[GetSlot,GetSlot,LoadConstant,OperatorInstruction,IsPlus,GetSlot,
GetSlot,LoadConstant,OperatorInstruction,GetSlot,SetSlot,GetSlot,
GetSlot,Branch] ,
[],[RegisterTransfer,GetSlot,FunctionReturn]]
@expect = [Label, SaveReturn,LoadConstant,GetSlot,SetSlot,Label,
GetSlot,GetSlot,LoadConstant,OperatorInstruction,IsPlus,
GetSlot, GetSlot,LoadConstant,OperatorInstruction, GetSlot,
SetSlot,GetSlot, GetSlot,Branch , Label ,
Label , RegisterTransfer,GetSlot,FunctionReturn]
check
end
end

View File

@ -16,7 +16,7 @@ class HelloTest < MiniTest::Test
writer.save "hello.o"
end
def test_string_put
def pest_string_put
@string_input = <<HERE
class Object
int main()

View File

@ -24,32 +24,22 @@ class AddTest < MiniTest::Test
@interpreter.start Register.machine.init
end
def test_branch
was = @interpreter.block
assert_equal Register::Branch , ticks(1).class
assert was != @interpreter.block
end
def test_load
assert_equal Register::LoadConstant , ticks(2).class
assert_equal Parfait::Space , Register.machine.objects[ @interpreter.get_register(:r2)].class
assert_equal :r2, @interpreter.instruction.array.symbol
end
def test_get
assert_equal Register::GetSlot , ticks(3).class
assert_equal Register::GetSlot , ticks(4).class
assert @interpreter.get_register( :r2 )
assert @interpreter.get_register( :r2 ).is_a? Integer
end
def test_transfer
transfer = ticks 5
transfer = ticks 6
assert_equal Register::RegisterTransfer , transfer.class
assert_equal @interpreter.get_register(transfer.to) , @interpreter.get_register(transfer.from)
end
def test_call
assert_equal Register::FunctionCall , ticks(6).class
assert_equal Register::FunctionCall , ticks(7).class
assert @interpreter.link
end
def test_adding
done_op = ticks(10)
done_op = ticks(12)
assert_equal Register::OperatorInstruction , done_op.class
left = @interpreter.get_register(done_op.left)
rr = done_op.right
@ -58,7 +48,7 @@ class AddTest < MiniTest::Test
assert_equal Fixnum , right.class
assert_equal 7 , right
assert_equal 12 , left
done_tr = ticks(1)
done_tr = ticks(2)
assert_equal Register::RegisterTransfer , done_tr.class
result = @interpreter.get_register(done_op.left)
assert_equal result , 12
@ -66,10 +56,10 @@ class AddTest < MiniTest::Test
def test_chain
#show_ticks # get output of what is
["Branch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
"FunctionCall","SaveReturn","LoadConstant","LoadConstant","OperatorInstruction",
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall",
"NilClass"].each_with_index do |name , index|
["Branch","Label","LoadConstant","GetSlot","SetSlot",
"RegisterTransfer","FunctionCall","Label","SaveReturn","LoadConstant",
"LoadConstant","OperatorInstruction","Label","RegisterTransfer","GetSlot",
"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

View File

@ -31,16 +31,18 @@ HERE
@interpreter = Interpreter::Interpreter.new
@interpreter.start Register.machine.init
#show_ticks # get output of what is
["Branch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
"FunctionCall","SaveReturn","GetSlot","GetSlot","SetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer",
"FunctionCall","SaveReturn","GetSlot","LoadConstant","OperatorInstruction",
"IsZero","GetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","RegisterTransfer","FunctionCall","SaveReturn","GetSlot",
"RegisterTransfer","Syscall","RegisterTransfer","RegisterTransfer","SetSlot",
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","Branch",
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","RegisterTransfer",
"GetSlot","FunctionReturn","RegisterTransfer","Syscall","NilClass"].each_with_index do |name , index|
["Branch","Label","LoadConstant","GetSlot","SetSlot",
"RegisterTransfer","FunctionCall","Label","SaveReturn","GetSlot",
"GetSlot","SetSlot","LoadConstant","SetSlot","LoadConstant",
"SetSlot","RegisterTransfer","FunctionCall","Label","SaveReturn",
"GetSlot","LoadConstant","OperatorInstruction","IsZero","GetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer",
"FunctionCall","Label","SaveReturn","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|
got = ticks(1)
assert got.class.name.index(name) , "Wrong class for #{index+1}, expect #{name} , got #{got}"
end

View File

@ -59,26 +59,30 @@ HERE
@interpreter = Interpreter::Interpreter.new
@interpreter.start Register.machine.init
#show_ticks # get output of what is
["Branch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
"FunctionCall","SaveReturn","GetSlot","LoadConstant","SetSlot",
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","SaveReturn",
"LoadConstant","GetSlot","SetSlot","GetSlot","GetSlot",
["Branch","Label","LoadConstant","GetSlot","SetSlot",
"RegisterTransfer","FunctionCall","Label","SaveReturn","GetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer",
"FunctionCall","Label","SaveReturn","LoadConstant","GetSlot",
"SetSlot","GetSlot","GetSlot","SetSlot","LoadConstant",
"SetSlot","GetSlot","GetSlot","SetSlot","RegisterTransfer",
"FunctionCall","Label","SaveReturn","GetSlot","LoadConstant",
"OperatorInstruction","GetSlot","SetSlot","GetSlot","GetSlot",
"GetSlot","OperatorInstruction","GetSlot","SetSlot","GetSlot",
"GetSlot","IsNotzero","Label","GetSlot","GetSlot",
"SetSlot","LoadConstant","SetSlot","GetSlot","GetSlot",
"SetSlot","RegisterTransfer","FunctionCall","SaveReturn","GetSlot",
"LoadConstant","OperatorInstruction","GetSlot","SetSlot","GetSlot",
"GetSlot","GetSlot","OperatorInstruction","GetSlot","SetSlot",
"GetSlot","GetSlot","IsNotzero","GetSlot","GetSlot",
"SetSlot","LoadConstant","SetSlot","GetSlot","GetSlot",
"SetSlot","RegisterTransfer","FunctionCall","SaveReturn","GetSlot",
"LoadConstant","OperatorInstruction","IsZero","Branch","GetSlot",
"LoadConstant","OperatorInstruction","IsZero","LoadConstant","GetSlot",
"LoadConstant","OperatorInstruction","IsZero","LoadConstant","GetSlot",
"LoadConstant","OperatorInstruction","IsZero","LoadConstant","GetSlot",
"LoadConstant","OperatorInstruction","IsZero","LoadConstant","RegisterTransfer",
"GetSlot","FunctionReturn","GetSlot","GetSlot","SetSlot",
"GetSlot","GetSlot","GetSlot","OperatorInstruction","SetSlot",
"GetSlot","RegisterTransfer","GetSlot","FunctionReturn","GetSlot",
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","RegisterTransfer",
"SetSlot","RegisterTransfer","FunctionCall","Label","SaveReturn",
"GetSlot","LoadConstant","OperatorInstruction","IsZero","Branch",
"Label","GetSlot","LoadConstant","OperatorInstruction","IsZero",
"Label","LoadConstant","Label","GetSlot","LoadConstant",
"OperatorInstruction","IsZero","Label","LoadConstant","Label",
"GetSlot","LoadConstant","OperatorInstruction","IsZero","Label",
"LoadConstant","Label","GetSlot","LoadConstant","OperatorInstruction",
"IsZero","Label","LoadConstant","Label","Label",
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","GetSlot",
"SetSlot","GetSlot","GetSlot","GetSlot","OperatorInstruction",
"SetSlot","Label","GetSlot","Label","RegisterTransfer",
"GetSlot","FunctionReturn","GetSlot","Label","RegisterTransfer",
"GetSlot","FunctionReturn","GetSlot","Label","RegisterTransfer",
"GetSlot","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}"

View File

@ -25,42 +25,44 @@ class TestPuts < MiniTest::Test
end
def test_branch
was = @interpreter.block
was = @interpreter.instruction
assert_equal Register::Branch , ticks(1).class
assert was != @interpreter.block
assert was != @interpreter.instruction
assert @interpreter.instruction , "should have gone to next instruction"
end
def test_load
assert_equal Register::LoadConstant , ticks(2).class
assert_equal Register::LoadConstant , ticks(3).class
assert_equal Parfait::Space , Register.machine.objects[ @interpreter.get_register(:r2)].class
assert_equal :r2, @interpreter.instruction.array.symbol
end
def test_get
assert_equal Register::GetSlot , ticks(3).class
assert_equal Register::GetSlot , ticks(4).class
assert @interpreter.get_register( :r1 )
assert @interpreter.get_register( :r1 ).is_a? Integer
end
def test_transfer
transfer = ticks 5
transfer = ticks 6
assert_equal Register::RegisterTransfer , transfer.class
assert_equal @interpreter.get_register(transfer.to) , @interpreter.get_register(transfer.from)
end
def test_call
assert_equal Register::FunctionCall , ticks(6).class
assert_equal Register::FunctionCall , ticks(7).class
assert @interpreter.link
end
def test_save
done = ticks(7)
done = ticks(9)
assert_equal Register::SaveReturn , done.class
assert @interpreter.get_register done.register.symbol
end
def test_chain
#show_ticks # get output of what is
["Branch","LoadConstant","GetSlot","SetSlot","RegisterTransfer",
"FunctionCall","SaveReturn","GetSlot","LoadConstant","SetSlot",
"LoadConstant","SetSlot","RegisterTransfer","FunctionCall","SaveReturn",
"GetSlot","RegisterTransfer","Syscall","RegisterTransfer","RegisterTransfer",
"SetSlot","RegisterTransfer","GetSlot","FunctionReturn","GetSlot",
[ "Branch","Label","LoadConstant","GetSlot","SetSlot",
"RegisterTransfer","FunctionCall","Label","SaveReturn","GetSlot",
"LoadConstant","SetSlot","LoadConstant","SetSlot","RegisterTransfer",
"FunctionCall","Label","SaveReturn","GetSlot","RegisterTransfer",
"Syscall","RegisterTransfer","RegisterTransfer","SetSlot","Label",
"RegisterTransfer","GetSlot","FunctionReturn","GetSlot","Label",
"RegisterTransfer","GetSlot","FunctionReturn","RegisterTransfer","Syscall",
"NilClass"].each_with_index do |name , index|
got = ticks(1)
@ -70,20 +72,20 @@ class TestPuts < MiniTest::Test
end
def test_putstring
done = ticks(18)
done = ticks(21)
assert_equal Register::Syscall , done.class
assert_equal "Hello again" , @interpreter.stdout
end
def test_return
done = ticks(24)
done = ticks(28)
assert_equal Register::FunctionReturn , done.class
assert @interpreter.block.is_a?(Register::Block)
assert Register::Label , @interpreter.instruction.class
assert @interpreter.instruction.is_a?(Register::Instruction) , "not instruction #{@interpreter.instruction}"
end
def test_exit
done = ticks(31)
done = ticks(36)
assert_equal NilClass , done.class
assert_equal "Hello again" , @interpreter.stdout
end