Fixing tests for implicit return

previous commit affected rather many test, as the implicit returns add extra instructions
Also added some explicit returns, so as not to test the return logic too much. return (ie return nl) is a knonwn 3 risc operation.
This commit is contained in:
2019-08-17 23:29:42 +03:00
parent 32f908c127
commit 5a43cbff15
43 changed files with 152 additions and 107 deletions

View File

@ -20,7 +20,7 @@ module Vool
assert_equal MessageSetup , @ins.class , @ins
end
def test_two_instructions_are_returned
assert_equal 6 , @ins.length , @ins
assert_equal 8 , @ins.length , @ins
end
def test_receiver_move_class
assert_equal ArgumentTransfer, @ins.next(1).class
@ -40,7 +40,8 @@ module Vool
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
end
def test_array
check_array [MessageSetup,ArgumentTransfer,SimpleCall,Label, ReturnSequence ,
check_array [MessageSetup,ArgumentTransfer,SimpleCall,
SlotLoad, ReturnJump, Label, ReturnSequence ,
Label] , @ins
end
end

View File

@ -21,7 +21,8 @@ module Vool
def test_array
check_array [NotSameCheck, SlotLoad, ResolveMethod, Label, MessageSetup ,
ArgumentTransfer, DynamicCall, Label, ReturnSequence, Label] , @ins
ArgumentTransfer, DynamicCall, SlotLoad, ReturnJump,
Label, ReturnSequence, Label] , @ins
end
end

View File

@ -7,14 +7,14 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
Risc.boot!
@compiler = compile_first_method( "a = main(1 + 2)" )
@compiler = compile_first_method( "a = main(1 + 2);return a" )
@ins = @compiler.mom_instructions.next
end
def test_array
check_array [MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad, MessageSetup ,
ArgumentTransfer, SimpleCall, SlotLoad ,Label, ReturnSequence ,
Label] , @ins
ArgumentTransfer, SimpleCall, SlotLoad ,SlotLoad, ReturnJump,
Label, ReturnSequence , Label] , @ins
end
def test_one_call

View File

@ -5,7 +5,7 @@ module Vool
include VoolCompile
def setup
@compiler = compile_first_method( "a = 5; a.div4")
@compiler = compile_first_method( "a = 5; a.div4;return ")
@ins = @compiler.mom_instructions.next
end
def test_check_type
@ -27,7 +27,8 @@ module Vool
def test_array
check_array [SlotLoad, NotSameCheck, SlotLoad, ResolveMethod ,
Label, MessageSetup, ArgumentTransfer, DynamicCall, Label ,
Label, MessageSetup, ArgumentTransfer, DynamicCall,
SlotLoad, ReturnJump, Label ,
ReturnSequence, Label] , @ins
end

View File

@ -5,7 +5,7 @@ module Vool
include SimpleSendHarness
def send_method
"self.get_internal_word(0)"
"self.get_internal_word(0);return"
end
def test_receiver
assert_equal SlotDefinition, @ins.next.receiver.class

View File

@ -5,7 +5,7 @@ module Vool
include SimpleSendHarness
def send_method
"5.div4"
"5.div4;return"
end
def receiver
[Mom::IntegerConstant , 5]

View File

@ -5,7 +5,7 @@ module Vool
include SimpleSendHarness
def send_method
"5.div4(1,2)"
"5.div4(1,2);return"
end
def receiver
@ -20,8 +20,8 @@ module Vool
assert_equal 2, @ins.next(1).arguments[1].right.known_object.value
end
def test_array
check_array [MessageSetup,ArgumentTransfer,SimpleCall, Label, ReturnSequence ,
Label] , @ins
check_array [MessageSetup,ArgumentTransfer,SimpleCall, SlotLoad, ReturnJump,
Label, ReturnSequence , Label] , @ins
end
end
end

View File

@ -5,7 +5,7 @@ module Vool
include SimpleSendHarness
def send_method
"'5'.get_internal_byte(1)"
"'5'.get_internal_byte(1) ; return "
end
def receiver
[Mom::StringConstant , "5"]