makes method_statements body always a scope_statement

This commit is contained in:
Torsten Ruger 2017-04-12 11:51:29 +03:00
parent 0d96f5e35f
commit a4b0666c8c
3 changed files with 34 additions and 4 deletions

View File

@ -32,6 +32,11 @@ module Vool
assert_equal clazz , space_class assert_equal clazz , space_class
end end
def test_class_body_is_scope
clazz = VoolCompiler.compile in_Test("def meth; @ivar ;end")
assert_equal ScopeStatement , clazz.body.class
end
def test_creates_class_without_deriviation def test_creates_class_without_deriviation
VoolCompiler.compile "class Testing ; end" VoolCompiler.compile "class Testing ; end"
clazz = Parfait.object_space.get_class_by_name(:Testing) clazz = Parfait.object_space.get_class_by_name(:Testing)

View File

@ -16,7 +16,8 @@ module Vool
def test_method_has_source def test_method_has_source
method = create_method method = create_method
assert_equal Vool::InstanceVariable , method.source.class assert_equal ScopeStatement , method.source.class
assert_equal InstanceVariable , method.source.statements.first.class
end end
def test_method_has_no_locals def test_method_has_no_locals
@ -35,11 +36,25 @@ module Vool
assert_equal Rubyx::RubyMethod , method.class assert_equal Rubyx::RubyMethod , method.class
end end
def test_creates_method_statement_in_class
clazz = VoolCompiler.compile in_Test("def meth; @ivar ;end")
assert_equal MethodStatement , clazz.body.statements.first.class
end
def test_parfait_class_creation
clazz = VoolCompiler.compile in_Test("def meth; @ivar ;end")
assert_equal Parfait::Class , clazz.body.statements.first.clazz.class
end
def test_method_statement_has_class def test_method_statement_has_class
clazz = VoolCompiler.compile in_Test("def meth; @ivar ;end") clazz = VoolCompiler.compile in_Test("def meth; @ivar ;end")
assert_equal ScopeStatement , clazz.body.class assert clazz.body.statements.first.clazz
assert_equal MethodStatement , clazz.body.statements.first.class end
assert_equal Parfait::Class , clazz.body.statements.first.clazz.class
def test_method_statement_has_class_in_main
clazz = VoolCompiler.compile as_main("def meth; @ivar ;end")
assert clazz.body.statements.first.clazz
end end
def test_method_has_one_local def test_method_has_one_local

View File

@ -26,5 +26,15 @@ module Vool
assert_equal ScopeStatement , @lst.body.class assert_equal ScopeStatement , @lst.body.class
assert_equal 2 , @lst.body.length assert_equal 2 , @lst.body.length
end end
def test_body_is_scope_one_statement
input = "def tryout(arg1, arg2) ; true ; end "
lst = RubyCompiler.compile( input )
assert_equal ScopeStatement , lst.body.class
end
def test_body_is_scope_zero_statement
input = "def tryout(arg1, arg2) ; ; end "
lst = RubyCompiler.compile( input )
assert_equal ScopeStatement , lst.body.class
end
end end
end end