start testing that compile returns slot

This commit is contained in:
Torsten Ruger 2015-07-19 12:31:57 +03:00
parent 849a92a909
commit 1f95d8994c
3 changed files with 30 additions and 1 deletions

View File

@ -1,3 +1,4 @@
require_relative "test_basic"
require_relative "test_methods"
require_relative "test_hello"
require_relative "test_compiler"

View File

@ -0,0 +1,29 @@
require_relative "compiler_helper"
class CompilerTest < MiniTest::Test
def setup
Virtual.machine.boot
end
def check
res = Virtual::Compiler.compile( @expression , Virtual.machine.space.get_main )
assert res.is_a?(Virtual::Slot) , "compiler must compile to slot, not #{res.class}"
end
def true_ex
Ast::TrueExpression.new
end
def name_ex
Ast::NameExpression.new("name#{rand(100)}")
end
def list
[true_ex]
end
def test_if_expression
@expression = Ast::IfExpression.new( true_ex , list , list)
check
end
def test_function_expression
@expression = Ast::FunctionExpression.new( "name", [] , [true_ex] ,nil)
check
end
end

View File

@ -1,7 +1,6 @@
require_relative "compiler_helper"
class HelloTest < MiniTest::Test
include CompilerHelper
def check
machine = Virtual.machine.boot