2015-11-08 12:39:13 +01:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
|
|
|
|
module Register
|
|
|
|
class TestFieldStatement < MiniTest::Test
|
|
|
|
include Statements
|
|
|
|
|
|
|
|
def test_field_frame
|
|
|
|
@string_input = <<HERE
|
|
|
|
class Object
|
|
|
|
int main()
|
2015-11-08 12:55:38 +01:00
|
|
|
Message m
|
|
|
|
return m.name
|
2015-11-08 12:39:13 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
2015-11-09 22:27:15 +01:00
|
|
|
@expect = [Label, GetSlot, GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
|
2015-11-08 12:39:13 +01:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_field_arg
|
|
|
|
@string_input = <<HERE
|
|
|
|
class Object
|
2015-11-08 12:55:38 +01:00
|
|
|
int get_name(Message main)
|
|
|
|
return main.name
|
2015-11-08 12:39:13 +01:00
|
|
|
end
|
|
|
|
int main()
|
2015-11-08 12:55:38 +01:00
|
|
|
Message m
|
|
|
|
return get_name(m)
|
2015-11-08 12:39:13 +01:00
|
|
|
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
|
2015-11-08 12:55:38 +01:00
|
|
|
|
|
|
|
def test_self_field
|
|
|
|
@string_input = <<HERE
|
|
|
|
class Object
|
|
|
|
int main()
|
|
|
|
Layout l = self.layout
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
|
|
|
@expect = [Label, GetSlot, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot ,
|
|
|
|
Label, FunctionReturn]
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_message_field
|
|
|
|
@string_input = <<HERE
|
|
|
|
class Object
|
|
|
|
int main()
|
|
|
|
Word name = message.name
|
|
|
|
return name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
2015-11-09 22:27:15 +01:00
|
|
|
@expect = [Label, RegisterTransfer, GetSlot, GetSlot, SetSlot, GetSlot, GetSlot ,
|
|
|
|
SetSlot, Label, FunctionReturn]
|
2015-11-08 12:55:38 +01:00
|
|
|
check
|
|
|
|
end
|
2015-11-08 12:39:13 +01:00
|
|
|
end
|
|
|
|
end
|