Booting functions again and send test
both class and normal sending tests at vool / mom level
This commit is contained in:
parent
2326081161
commit
a4b6f29834
@ -20,7 +20,7 @@ module Risc
|
|||||||
# module method to reset, and init
|
# module method to reset, and init
|
||||||
def self.boot!
|
def self.boot!
|
||||||
Position.clear_positions
|
Position.clear_positions
|
||||||
# Builtin.boot_functions
|
Builtin.boot_functions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,12 +4,13 @@ module Vool
|
|||||||
# relies on @ins and receiver_type method
|
# relies on @ins and receiver_type method
|
||||||
|
|
||||||
module ClassHarness
|
module ClassHarness
|
||||||
include MomCompile
|
include VoolCompile
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
#Risc::Builtin.boot_functions
|
Risc.boot!
|
||||||
@ins = compile_first_method( send_method )
|
@compiler = compile_first_method( send_method )
|
||||||
|
@ins = @compiler.mom_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_first_not_array
|
def test_first_not_array
|
||||||
@ -19,7 +20,7 @@ module Vool
|
|||||||
assert_equal Mom::MessageSetup , @ins.class , @ins
|
assert_equal Mom::MessageSetup , @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_two_instructions_are_returned
|
def test_two_instructions_are_returned
|
||||||
assert_equal 3 , @ins.length , @ins
|
assert_equal 6 , @ins.length , @ins
|
||||||
end
|
end
|
||||||
def test_receiver_move_class
|
def test_receiver_move_class
|
||||||
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
|
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
|
||||||
@ -37,7 +38,8 @@ module Vool
|
|||||||
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
|
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
|
||||||
end
|
end
|
||||||
def test_array
|
def test_array
|
||||||
check_array [Mom::MessageSetup,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
|
check_array [MessageSetup,ArgumentTransfer,SimpleCall,Label,
|
||||||
|
ReturnSequence , Label] , @ins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,16 +17,8 @@ module Vool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
statements = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_vool(class_main)
|
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(class_main)
|
||||||
assert_equal Vool::ClassStatement, statements.class
|
@ins = ret.compilers.first.mom_instructions.next
|
||||||
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 )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_any
|
def test_any
|
||||||
@ -35,7 +27,7 @@ module Vool
|
|||||||
|
|
||||||
def test_no_arg
|
def test_no_arg
|
||||||
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
|
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
|
end
|
||||||
def test_call_two
|
def test_call_two
|
||||||
assert_equal SimpleCall, @ins.next(2).class
|
assert_equal SimpleCall, @ins.next(2).class
|
||||||
|
@ -2,7 +2,6 @@ require_relative "helper"
|
|||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class ClassSendHarness < MiniTest::Test
|
class ClassSendHarness < MiniTest::Test
|
||||||
include MomCompile
|
|
||||||
include ClassHarness
|
include ClassHarness
|
||||||
|
|
||||||
def send_method
|
def send_method
|
||||||
|
@ -3,7 +3,6 @@ require_relative "helper"
|
|||||||
module Vool
|
module Vool
|
||||||
class TestSendClassMom < MiniTest::Test
|
class TestSendClassMom < MiniTest::Test
|
||||||
include ClassHarness
|
include ClassHarness
|
||||||
include Mom
|
|
||||||
|
|
||||||
def send_method
|
def send_method
|
||||||
"Object.get_internal_word(0)"
|
"Object.get_internal_word(0)"
|
||||||
|
@ -4,27 +4,29 @@ module Vool
|
|||||||
# relies on @ins and receiver_type method
|
# relies on @ins and receiver_type method
|
||||||
module SimpleSendHarness
|
module SimpleSendHarness
|
||||||
include VoolCompile
|
include VoolCompile
|
||||||
|
include Mom
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
#Risc::Builtin.boot_functions
|
Risc::Builtin.boot_functions
|
||||||
@ins = compile_first_method( send_method )
|
@compiler = compile_first_method( send_method )
|
||||||
|
@ins = @compiler.mom_instructions.next
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_first_not_array
|
def test_first_not_array
|
||||||
assert Array != @ins.class , @ins
|
assert Array != @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_class_compiles
|
def test_class_compiles
|
||||||
assert_equal Mom::MessageSetup , @ins.class , @ins
|
assert_equal MessageSetup , @ins.class , @ins
|
||||||
end
|
end
|
||||||
def test_two_instructions_are_returned
|
def test_two_instructions_are_returned
|
||||||
assert_equal 3 , @ins.length , @ins
|
assert_equal 6 , @ins.length , @ins
|
||||||
end
|
end
|
||||||
def test_receiver_move_class
|
def test_receiver_move_class
|
||||||
assert_equal Mom::ArgumentTransfer, @ins.next(1).class
|
assert_equal ArgumentTransfer, @ins.next(1).class
|
||||||
end
|
end
|
||||||
def test_receiver_move
|
def test_receiver_move
|
||||||
assert_equal Mom::SlotDefinition, @ins.next.receiver.class
|
assert_equal SlotDefinition, @ins.next.receiver.class
|
||||||
end
|
end
|
||||||
def test_receiver
|
def test_receiver
|
||||||
type , value = receiver
|
type , value = receiver
|
||||||
@ -32,13 +34,14 @@ module Vool
|
|||||||
assert_equal value, @ins.next.receiver.known_object.value
|
assert_equal value, @ins.next.receiver.known_object.value
|
||||||
end
|
end
|
||||||
def test_call_is
|
def test_call_is
|
||||||
assert_equal Mom::SimpleCall, @ins.next(2).class
|
assert_equal SimpleCall, @ins.next(2).class
|
||||||
end
|
end
|
||||||
def test_call_has_method
|
def test_call_has_method
|
||||||
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
|
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
|
||||||
end
|
end
|
||||||
def test_array
|
def test_array
|
||||||
check_array [Mom::MessageSetup,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
|
check_array [MessageSetup,ArgumentTransfer,SimpleCall,Label, ReturnSequence ,
|
||||||
|
Label] , @ins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,8 +2,7 @@ require_relative "helper"
|
|||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSendArgsSendMom < MiniTest::Test
|
class TestSendArgsSendMom < MiniTest::Test
|
||||||
include MomCompile
|
include VoolCompile
|
||||||
include Mom
|
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
@ -14,7 +13,8 @@ module Vool
|
|||||||
|
|
||||||
def test_array
|
def test_array
|
||||||
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, MessageSetup ,
|
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, MessageSetup ,
|
||||||
ArgumentTransfer, SimpleCall, SlotLoad] , @ins
|
ArgumentTransfer, SimpleCall, SlotLoad ,Label, ReturnSequence ,
|
||||||
|
Label] , @ins
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_one_call
|
def test_one_call
|
||||||
|
@ -2,34 +2,34 @@ require_relative "../helper"
|
|||||||
|
|
||||||
module Vool
|
module Vool
|
||||||
class TestSendCachedSimpleMom < MiniTest::Test
|
class TestSendCachedSimpleMom < MiniTest::Test
|
||||||
include MomCompile
|
include VoolCompile
|
||||||
include Mom
|
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!(Parfait.default_test_options)
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
@compiler = compile_first_method( "a = 5; a.div4")
|
@compiler = compile_first_method( "a = 5; a.div4")
|
||||||
@ins = @compiler.mom_instructions.next
|
@ins = @compiler.mom_instructions.next
|
||||||
end
|
end
|
||||||
def pest_check_type
|
def test_check_type
|
||||||
assert_equal NotSameCheck , @ins.next.class , @ins
|
assert_equal NotSameCheck , @ins.next.class , @ins
|
||||||
end
|
end
|
||||||
def pest_type_update
|
def test_type_update
|
||||||
load = @ins.next(2)
|
load = @ins.next(2)
|
||||||
assert_equal :message , load.right.known_object , load
|
assert_equal :message , load.right.known_object , load
|
||||||
assert_equal :frame , load.right.slots[0] , load
|
assert_equal :frame , load.right.slots[0] , load
|
||||||
assert_equal :a , load.right.slots[1] , load
|
assert_equal :a , load.right.slots[1] , load
|
||||||
assert_equal :type , load.right.slots[2] , load
|
assert_equal :type , load.right.slots[2] , load
|
||||||
end
|
end
|
||||||
def pest_check_resolve_call
|
def test_check_resolve_call
|
||||||
assert_equal ResolveMethod , @ins.next(3).class , @ins
|
assert_equal ResolveMethod , @ins.next(3).class , @ins
|
||||||
end
|
end
|
||||||
def pest_dynamic_call_last
|
def test_dynamic_call_last
|
||||||
assert_equal DynamicCall , @ins.last.class , @ins
|
assert_equal DynamicCall , @ins.next(7).class , @ins
|
||||||
end
|
end
|
||||||
|
|
||||||
def pest_array
|
def test_array
|
||||||
check_array [SlotLoad, NotSameCheck, SlotLoad, ResolveMethod, Label, MessageSetup ,
|
check_array [SlotLoad, NotSameCheck, SlotLoad, ResolveMethod, Label, MessageSetup ,
|
||||||
ArgumentTransfer, DynamicCall] , @ins
|
ArgumentTransfer, DynamicCall, Label, ReturnSequence ,
|
||||||
|
Label] , @ins
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,6 @@ require_relative "helper"
|
|||||||
module Vool
|
module Vool
|
||||||
class TestSendSelfMom < MiniTest::Test
|
class TestSendSelfMom < MiniTest::Test
|
||||||
include SimpleSendHarness
|
include SimpleSendHarness
|
||||||
include Mom
|
|
||||||
|
|
||||||
def send_method
|
def send_method
|
||||||
"self.get_internal_word(0)"
|
"self.get_internal_word(0)"
|
||||||
|
@ -20,7 +20,8 @@ module Vool
|
|||||||
assert_equal 2, @ins.next(1).arguments[1].right.known_object.value
|
assert_equal 2, @ins.next(1).arguments[1].right.known_object.value
|
||||||
end
|
end
|
||||||
def test_array
|
def test_array
|
||||||
check_array [Mom::MessageSetup,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
|
check_array [MessageSetup,ArgumentTransfer,SimpleCall, Label, ReturnSequence ,
|
||||||
|
Label] , @ins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user