Booting functions again and send test

both class and normal sending tests at vool / mom level
This commit is contained in:
Torsten Rüger 2019-08-12 11:57:32 +03:00
parent 2326081161
commit a4b6f29834
10 changed files with 36 additions and 41 deletions

View File

@ -20,7 +20,7 @@ module Risc
# module method to reset, and init
def self.boot!
Position.clear_positions
# Builtin.boot_functions
Builtin.boot_functions
end
end

View File

@ -4,12 +4,13 @@ module Vool
# relies on @ins and receiver_type method
module ClassHarness
include MomCompile
include VoolCompile
def setup
Parfait.boot!(Parfait.default_test_options)
#Risc::Builtin.boot_functions
@ins = compile_first_method( send_method )
Risc.boot!
@compiler = compile_first_method( send_method )
@ins = @compiler.mom_instructions.next
end
def test_first_not_array
@ -19,7 +20,7 @@ module Vool
assert_equal Mom::MessageSetup , @ins.class , @ins
end
def test_two_instructions_are_returned
assert_equal 3 , @ins.length , @ins
assert_equal 6 , @ins.length , @ins
end
def test_receiver_move_class
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
@ -37,7 +38,8 @@ module Vool
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
end
def test_array
check_array [Mom::MessageSetup,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
check_array [MessageSetup,ArgumentTransfer,SimpleCall,Label,
ReturnSequence , Label] , @ins
end
end

View File

@ -17,16 +17,8 @@ module Vool
end
def setup
statements = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_vool(class_main)
assert_equal Vool::ClassStatement, statements.class
ret = statements.to_mom(nil)
assert_equal Parfait::Class , statements.clazz.class , statements
@method = statements.clazz.get_method(:main)
assert_equal Parfait::VoolMethod , @method.class
assert_equal Mom::MomCompiler , ret.class
compiler = ret.method_compilers.find{|c| c.get_method.name == :main }
assert_equal Risc::MethodCompiler , compiler.class
@ins = @method.source.to_mom( compiler )
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(class_main)
@ins = ret.compilers.first.mom_instructions.next
end
def test_any
@ -35,7 +27,7 @@ module Vool
def test_no_arg
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
assert_equal 0, @ins.next(1).arguments.length
assert_equal 1, @ins.next(1).arguments.length
end
def test_call_two
assert_equal SimpleCall, @ins.next(2).class

View File

@ -2,7 +2,6 @@ require_relative "helper"
module Vool
class ClassSendHarness < MiniTest::Test
include MomCompile
include ClassHarness
def send_method

View File

@ -3,7 +3,6 @@ require_relative "helper"
module Vool
class TestSendClassMom < MiniTest::Test
include ClassHarness
include Mom
def send_method
"Object.get_internal_word(0)"

View File

@ -4,27 +4,29 @@ module Vool
# relies on @ins and receiver_type method
module SimpleSendHarness
include VoolCompile
include Mom
def setup
Parfait.boot!(Parfait.default_test_options)
#Risc::Builtin.boot_functions
@ins = compile_first_method( send_method )
Risc::Builtin.boot_functions
@compiler = compile_first_method( send_method )
@ins = @compiler.mom_instructions.next
end
def test_first_not_array
assert Array != @ins.class , @ins
end
def test_class_compiles
assert_equal Mom::MessageSetup , @ins.class , @ins
assert_equal MessageSetup , @ins.class , @ins
end
def test_two_instructions_are_returned
assert_equal 3 , @ins.length , @ins
assert_equal 6 , @ins.length , @ins
end
def test_receiver_move_class
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
assert_equal ArgumentTransfer, @ins.next(1).class
end
def test_receiver_move
assert_equal Mom::SlotDefinition, @ins.next.receiver.class
assert_equal SlotDefinition, @ins.next.receiver.class
end
def test_receiver
type , value = receiver
@ -32,13 +34,14 @@ module Vool
assert_equal value, @ins.next.receiver.known_object.value
end
def test_call_is
assert_equal Mom::SimpleCall, @ins.next(2).class
assert_equal SimpleCall, @ins.next(2).class
end
def test_call_has_method
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
end
def test_array
check_array [Mom::MessageSetup,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
check_array [MessageSetup,ArgumentTransfer,SimpleCall,Label, ReturnSequence ,
Label] , @ins
end
end
end

View File

@ -2,8 +2,7 @@ require_relative "helper"
module Vool
class TestSendArgsSendMom < MiniTest::Test
include MomCompile
include Mom
include VoolCompile
def setup
Parfait.boot!(Parfait.default_test_options)
@ -14,7 +13,8 @@ module Vool
def test_array
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, MessageSetup ,
ArgumentTransfer, SimpleCall, SlotLoad] , @ins
ArgumentTransfer, SimpleCall, SlotLoad ,Label, ReturnSequence ,
Label] , @ins
end
def test_one_call

View File

@ -2,34 +2,34 @@ require_relative "../helper"
module Vool
class TestSendCachedSimpleMom < MiniTest::Test
include MomCompile
include Mom
include VoolCompile
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "a = 5; a.div4")
@ins = @compiler.mom_instructions.next
end
def pest_check_type
def test_check_type
assert_equal NotSameCheck , @ins.next.class , @ins
end
def pest_type_update
def test_type_update
load = @ins.next(2)
assert_equal :message , load.right.known_object , load
assert_equal :frame , load.right.slots[0] , load
assert_equal :a , load.right.slots[1] , load
assert_equal :type , load.right.slots[2] , load
end
def pest_check_resolve_call
def test_check_resolve_call
assert_equal ResolveMethod , @ins.next(3).class , @ins
end
def pest_dynamic_call_last
assert_equal DynamicCall , @ins.last.class , @ins
def test_dynamic_call_last
assert_equal DynamicCall , @ins.next(7).class , @ins
end
def pest_array
def test_array
check_array [SlotLoad, NotSameCheck, SlotLoad, ResolveMethod, Label, MessageSetup ,
ArgumentTransfer, DynamicCall] , @ins
ArgumentTransfer, DynamicCall, Label, ReturnSequence ,
Label] , @ins
end
end

View File

@ -3,7 +3,6 @@ require_relative "helper"
module Vool
class TestSendSelfMom < MiniTest::Test
include SimpleSendHarness
include Mom
def send_method
"self.get_internal_word(0)"

View File

@ -20,7 +20,8 @@ module Vool
assert_equal 2, @ins.next(1).arguments[1].right.known_object.value
end
def test_array
check_array [Mom::MessageSetup,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
check_array [MessageSetup,ArgumentTransfer,SimpleCall, Label, ReturnSequence ,
Label] , @ins
end
end
end