2015-10-25 12:19:18 +01:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
module Register
|
|
|
|
class TestBasicClass < MiniTest::Test
|
|
|
|
include Statements
|
|
|
|
|
2015-10-26 16:23:35 +01:00
|
|
|
def test_class_def
|
2015-10-25 12:19:18 +01:00
|
|
|
@string_input = <<HERE
|
|
|
|
class Bar
|
2015-10-25 14:40:12 +01:00
|
|
|
int self.buh()
|
2015-10-25 12:19:18 +01:00
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class Object
|
|
|
|
int main()
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
|
|
|
@expect = [Label, SaveReturn,LoadConstant,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
|
|
|
check
|
|
|
|
end
|
2015-10-26 12:08:40 +01:00
|
|
|
|
2015-10-26 21:23:06 +01:00
|
|
|
def test_class_call
|
|
|
|
@string_input = <<HERE
|
|
|
|
class Bar
|
|
|
|
int self.buh()
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class Object
|
|
|
|
int main()
|
|
|
|
return Bar.buh()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
|
|
|
@length = 30
|
|
|
|
@expect = [Label, SaveReturn,GetSlot,LoadConstant,SetSlot,LoadConstant,SetSlot,
|
|
|
|
RegisterTransfer,FunctionCall,GetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-10-26 12:08:40 +01:00
|
|
|
def test_class_field_value
|
|
|
|
@string_input = <<HERE
|
|
|
|
class Object
|
|
|
|
field int boo = 1
|
|
|
|
int main()
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
|
|
|
@expect = [Label, SaveReturn,LoadConstant,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
|
|
|
assert_raises{check}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_class_field
|
|
|
|
@string_input = <<HERE
|
|
|
|
class Object
|
|
|
|
field int boo
|
|
|
|
int main()
|
|
|
|
return self.boo
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
2015-10-26 21:23:06 +01:00
|
|
|
@length = 17
|
2015-10-26 12:08:40 +01:00
|
|
|
@expect = [Label, SaveReturn,GetSlot,GetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
|
|
|
|
check
|
|
|
|
end
|
2015-10-25 12:19:18 +01:00
|
|
|
end
|
|
|
|
end
|