rubyx/stash/soml/statements/test_class.rb

57 lines
1003 B
Ruby
Raw Normal View History

2015-10-25 12:19:18 +01:00
require_relative 'helper'
module Register
2015-10-27 10:00:48 +01:00
class TestClassStatements < MiniTest::Test
2015-10-25 12:19:18 +01:00
include Statements
def test_class_defs
2015-10-25 12:19:18 +01:00
@string_input = <<HERE
class Bar
int self.buh()
2015-10-25 12:19:18 +01:00
return 1
end
end
2015-11-30 15:20:39 +01:00
class Space
2015-10-25 12:19:18 +01:00
int main()
return 1
end
end
HERE
@expect = [Label, LoadConstant,SetSlot,Label,FunctionReturn]
2015-10-25 12:19:18 +01:00
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
2015-11-30 15:20:39 +01:00
class Space
2015-10-26 21:23:06 +01:00
int main()
return Bar.buh()
end
end
HERE
@expect = [Label, GetSlot, LoadConstant, SetSlot, LoadConstant, SetSlot, LoadConstant ,
SetSlot, LoadConstant, SetSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
GetSlot, GetSlot, SetSlot, Label, FunctionReturn]
2015-10-26 21:23:06 +01:00
check
end
2015-10-26 12:08:40 +01:00
def test_class_field
@string_input = <<HERE
2015-11-30 15:20:39 +01:00
class Space
2015-11-02 16:32:06 +01:00
field int boo2
2015-10-26 12:08:40 +01:00
int main()
2015-11-02 16:32:06 +01:00
return self.boo2
2015-10-26 12:08:40 +01:00
end
end
HERE
@expect = [Label, GetSlot,GetSlot,SetSlot,Label,FunctionReturn]
2015-10-26 12:08:40 +01:00
check
end
2015-10-25 12:19:18 +01:00
end
end