implement and test field access

This commit is contained in:
Torsten Ruger
2015-11-08 13:39:13 +02:00
parent b443103ea4
commit 502cfa357d
3 changed files with 62 additions and 5 deletions

View File

@ -0,0 +1,46 @@
require_relative 'helper'
module Register
class TestFieldStatement < MiniTest::Test
include Statements
def test_field_frame
@string_input = <<HERE
class Fielded
field int one
end
class Object
int main()
Fielded f
return f.one
end
end
HERE
@expect = [Label, GetSlot, SetSlot, Label, FunctionReturn]
check
end
def test_field_arg
@string_input = <<HERE
class Fielded
field int one
end
class Object
int the_one(Fielded f)
return f.one
end
int main()
Fielded f
return the_one(f)
end
end
HERE
@expect = [Label, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot, RegisterTransfer ,
FunctionCall, Label, RegisterTransfer, GetSlot, GetSlot, SetSlot, Label ,
FunctionReturn]
check
end
end
end