some class field tests

This commit is contained in:
Torsten Ruger 2015-10-26 13:08:40 +02:00
parent dc58dbe2fe
commit b76c140d32
2 changed files with 28 additions and 4 deletions

View File

@ -12,10 +12,8 @@ module Soml
#puts "Define field #{name} on class #{for_class.name}" #puts "Define field #{name} on class #{for_class.name}"
index = for_class.object_layout.add_instance_variable( name ) #TODO need typing index = for_class.object_layout.add_instance_variable( name ) #TODO need typing
if value # not sure how to run class code yet. later
value = process( value ) raise "value #{value}" if value
raise "value #{value}" #tbc
end
return nil # statements don't reurn values, only expressions return nil # statements don't reurn values, only expressions
end end

View File

@ -20,5 +20,31 @@ HERE
@expect = [Label, SaveReturn,LoadConstant,Label,RegisterTransfer,GetSlot,FunctionReturn] @expect = [Label, SaveReturn,LoadConstant,Label,RegisterTransfer,GetSlot,FunctionReturn]
check check
end end
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
@expect = [Label, SaveReturn,GetSlot,GetSlot,Label,RegisterTransfer,GetSlot,FunctionReturn]
check
end
end end
end end