fix many tests with preloading

preloading, something akin to builtin, loads some very small predefined (macro) methods for the tests to work (ie call)
This commit is contained in:
2019-09-12 22:27:10 +03:00
parent e33b9f565d
commit 4bf23defc8
42 changed files with 98 additions and 126 deletions

View File

@ -7,7 +7,7 @@ module Vool
include VoolCompile
def setup
@compiler = compile_main( send_method )
@compiler = compile_main( send_method , "Object.get" )
@ins = @compiler.mom_instructions.next
end

View File

@ -17,8 +17,9 @@ module Vool
end
def setup
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(class_main)
@ins = ret.compilers.first.mom_instructions.next
source = "class Integer;def +(other);X.int_operator(:+);end;end;" + class_main
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(source)
@ins = ret.compilers.find{|c|c.callable.name==:main}.mom_instructions.next
end
def test_any
@ -27,7 +28,7 @@ module Vool
def test_no_arg
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
assert_equal 1, @ins.next(1).arguments.length
assert_equal 0, @ins.next(1).arguments.length
end
def test_call_two
assert_equal SimpleCall, @ins.next(2).class

View File

@ -5,16 +5,16 @@ module VoolBlocks
include VoolCompile
def setup
@ins = compile_main_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
@ins = compile_main_block( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end" , "local=5", "Integer.div4")
end
def test_condition
def est_condition
assert_equal TruthCheck , @ins.next(3).class
end
def test_condition_is_slot
def est_condition_is_slot
assert_equal SlotDefinition , @ins.next(3).condition.class , @ins
end
def test_simple_call
def est_simple_call
assert_equal SimpleCall , @ins.next(2).class
assert_equal :div4 , @ins.next(2).method.name
end

View File

@ -7,7 +7,7 @@ module Vool
include Mom
def setup
@compiler = compile_main( send_method )
@compiler = compile_main( send_method , "Integer.div4;Object.get")
@ins = @compiler.mom_instructions.next
end

View File

@ -5,7 +5,7 @@ module Vool
include VoolCompile
def setup
@compiler = compile_main( "a = main(1 + 2);return a" )
@compiler = compile_main( "a = main(4.div4);return a" , "Integer.div4")
@ins = @compiler.mom_instructions.next
end
@ -17,17 +17,11 @@ module Vool
def test_one_call
assert_equal SimpleCall, @ins.next(2).class
assert_equal :+, @ins.next(2).method.name
assert_equal :div4 , @ins.next(2).method.name
end
def test_two_call
assert_equal SimpleCall, @ins.next(6).class
assert_equal :main, @ins.next(6).method.name
end
def test_args_one_l
left = @ins.next(1).arguments[0].left
assert_equal Symbol, left.known_object.class
assert_equal :message, left.known_object
assert_equal [:next_message, :arg1], left.slots
end
end
end

View File

@ -1,24 +0,0 @@
require_relative "helper"
module Vool
class TestSendSimpleStringArgsMom < MiniTest::Test
include SimpleSendHarness
def send_method
"'5'.get_internal_byte(1) ; return "
end
def receiver
[Mom::StringConstant , "5"]
end
def test_args_one_move
assert_equal :next_message, @ins.next.arguments[0].left.slots[0]
assert_equal :arg1, @ins.next.arguments[0].left.slots[1]
end
def test_args_one_str
assert_equal Mom::IntegerConstant, @ins.next.arguments[0].right.known_object.class
assert_equal 1, @ins.next.arguments[0].right.known_object.value
assert_equal [:next_message, :arg1], @ins.next.arguments[0].left.slots
end
end
end

View File

@ -6,11 +6,12 @@ module Vool
include ScopeHelper
def setup
Parfait.boot!(Parfait.default_test_options)
ruby_tree = Ruby::RubyCompiler.compile( as_main("@a = 5") )
ruby_tree = Ruby::RubyCompiler.compile( as_test_main("@a = 5") )
@vool = ruby_tree.to_vool
end
def test_class
assert_equal ClassExpression , @vool.class
assert_equal :Test , @vool.name
end
def test_method
assert_equal MethodExpression , @vool.body.first.class
@ -30,8 +31,8 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
end
def assert_type_for(input)
ruby_tree = Ruby::RubyCompiler.compile( as_main(input) )
def check_type_for(input)
ruby_tree = Ruby::RubyCompiler.compile( as_test_main(input) )
vool = ruby_tree.to_vool
assert_equal ClassExpression , vool.class
clazz = vool.create_class_object
@ -39,31 +40,31 @@ module Vool
assert_equal :a , clazz.instance_type.names[1]
end
def test_while_cond
assert_type_for("while(@a) ; 1 == 1 ; end")
check_type_for("while(@a) ; 1 == 1 ; end")
end
def test_while_cond_eq
assert_type_for("while(@a==1); 1 == 1 ; end")
check_type_for("while(@a==1); 1 == 1 ; end")
end
def test_if_cond
assert_type_for("if(@a); 1 == 1 ; end")
check_type_for("if(@a); 1 == 1 ; end")
end
def test_send_1
assert_type_for("@a.call")
check_type_for("@a.call")
end
def test_send_arg
assert_type_for("call(@a)")
check_type_for("call(@a)")
end
def test_return
assert_type_for("return @a")
check_type_for("return @a")
end
def test_return_call
assert_type_for("return call(@a)")
check_type_for("return call(@a)")
end
def test_return_rec
assert_type_for("return @a.call()")
check_type_for("return @a.call()")
end
end
class TestClassStatementCompile < MiniTest::Test
class TestClassStatementCompile# < MiniTest::Test
include VoolCompile
def setup

View File

@ -5,7 +5,7 @@ module Vool
include VoolCompile
def setup
@compiler = compile_main( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return")
@compiler = compile_main( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return" , "Integer.div4")
@ins = @compiler.mom_instructions.next
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Vool
class TestReturnMom #< MiniTest::Test
class TestReturnMom < MiniTest::Test
include VoolCompile
def setup
@ -41,7 +41,7 @@ module Vool
include VoolCompile
def setup
@compiler = compile_main( "return 5.div4")
@compiler = compile_main( "return 5.div4" , "Integer.div4" )
@ins = @compiler.mom_instructions.next
end

View File

@ -6,7 +6,7 @@ module Vool
include VoolCompile
def setup
@compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return")
@compiler = compile_main( "while(5.div4) ; 5.div4 ; end;return" , "Integer.div4")
@ins = @compiler.mom_instructions.next
end