2017-04-02 18:13:14 +02:00
|
|
|
require_relative "helper"
|
2017-04-01 14:57:39 +02:00
|
|
|
|
|
|
|
module Vool
|
2017-04-09 08:59:21 +02:00
|
|
|
class TestEmptyClassStatement < MiniTest::Test
|
2017-04-01 14:57:39 +02:00
|
|
|
|
|
|
|
def setup
|
|
|
|
input = "class Tryout < Base;end"
|
2017-04-06 14:36:41 +02:00
|
|
|
@lst = RubyCompiler.compile( input )
|
2017-04-01 14:57:39 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_compile_class
|
|
|
|
assert_equal ClassStatement , @lst.class
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_compile_class_name
|
|
|
|
assert_equal :Tryout , @lst.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_compile_class_super
|
|
|
|
assert_equal :Base , @lst.super_class_name
|
|
|
|
end
|
|
|
|
|
2017-04-01 15:27:32 +02:00
|
|
|
def test_compile_class_body
|
2017-04-09 08:59:21 +02:00
|
|
|
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
|
2017-04-01 15:27:32 +02:00
|
|
|
end
|
|
|
|
|
2017-04-01 14:57:39 +02:00
|
|
|
end
|
|
|
|
end
|