fix class statements to always have Statements as body

not sometimes an array, which sits badly in the tree of statements
This commit is contained in:
Torsten Ruger
2017-04-09 09:59:21 +03:00
parent a6e87491cd
commit 397eca541a
2 changed files with 24 additions and 3 deletions

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Vool
class TestClassStatement < MiniTest::Test
class TestEmptyClassStatement < MiniTest::Test
def setup
input = "class Tryout < Base;end"
@ -21,7 +21,23 @@ module Vool
end
def test_compile_class_body
assert_equal [] , @lst.body
assert_equal 0 , @lst.body.length
assert_equal ScopeStatement , @lst.body.class
end
end
class TestBasicClassStatement < MiniTest::Test
include CompilerHelper
def test_compile_one_method
lst = RubyCompiler.compile( in_Test("@ivar") )
assert_equal ScopeStatement , lst.body.class
assert_equal InstanceVariable , lst.body.statements.first.class
end
def test_compile_two_methods
lst = RubyCompiler.compile( in_Test("false; true;") )
assert_equal ScopeStatement , lst.body.class
assert_equal TrueStatement , lst.body.statements[1].class
end
end