start testing that compile returns slot
This commit is contained in:
parent
849a92a909
commit
1f95d8994c
@ -1,3 +1,4 @@
|
||||
require_relative "test_basic"
|
||||
require_relative "test_methods"
|
||||
require_relative "test_hello"
|
||||
require_relative "test_compiler"
|
||||
|
29
test/compiler/test_compiler.rb
Normal file
29
test/compiler/test_compiler.rb
Normal 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
|
@ -1,7 +1,6 @@
|
||||
require_relative "compiler_helper"
|
||||
|
||||
class HelloTest < MiniTest::Test
|
||||
include CompilerHelper
|
||||
|
||||
def check
|
||||
machine = Virtual.machine.boot
|
||||
|
Loading…
Reference in New Issue
Block a user