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 Mom::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 Mom::ArgumentTransfer, @ins.next(1).class
@ -38,8 +38,8 @@ module Vool
assert_equal Parfait::CallableMethod, @ins.next(2).method.class
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

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"]

View File

@ -6,7 +6,7 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "local = 5")
@compiler = compile_first_method( "local = 5;return")
@ins = @compiler.mom_instructions.next
end
@ -38,7 +38,7 @@ module Vool
include VoolCompile
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "@a = 5 ; local = @a")
@compiler = compile_first_method( "@a = 5 ; local = @a;return")
@ins = @compiler.mom_instructions.next
end
def test_class_compiles
@ -52,7 +52,7 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "arg = 5")
@compiler = compile_first_method( "arg = 5;return")
@ins = @compiler.mom_instructions.next
end
@ -79,13 +79,13 @@ module Vool
Parfait.boot!(Parfait.default_test_options)
end
def test_assigns_const
@compiler = compile_first_method( "@a = 5")
@compiler = compile_first_method( "@a = 5;return")
@ins = @compiler.mom_instructions.next
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
end
def test_assigns_move
@compiler = compile_first_method( "@a = arg")
@compiler = compile_first_method( "@a = arg;return")
@ins = @compiler.mom_instructions.next
assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::SlotDefinition , @ins.right.class , @ins

View File

@ -67,7 +67,7 @@ module Vool
include VoolCompile
def setup
@compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end")
@compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end; return")
@ins = @compiler.mom_instructions
end
@ -89,8 +89,8 @@ module Vool
end
def test_array
check_array [Label, TruthCheck, Label, SlotLoad, Jump ,
Label, SlotLoad, Label, Label, ReturnSequence ,
Label] , @ins
Label, SlotLoad, Label, SlotLoad, ReturnJump ,
Label, ReturnSequence, Label] , @ins
end
end
end

View File

@ -7,7 +7,7 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "if(@a) ; @a = 5 ; end")
@compiler = compile_first_method( "if(@a) ; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next
end
@ -24,8 +24,8 @@ module Vool
assert_equal Label , @ins.last.class , @ins
end
def test_array
check_array [TruthCheck, Label, SlotLoad, Label, Label ,
ReturnSequence, Label], @ins
check_array [TruthCheck, Label, SlotLoad, Label, SlotLoad, ReturnJump,
Label ,ReturnSequence, Label], @ins
end
end
end

View File

@ -7,7 +7,7 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "unless(@a) ; @a = 5 ; end")
@compiler = compile_first_method( "unless(@a) ; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next
end
@ -25,7 +25,7 @@ module Vool
end
def test_array
check_array [TruthCheck, Label, Jump, Label, SlotLoad ,
Label, Label, ReturnSequence, Label] , @ins
Label, SlotLoad, ReturnJump,Label, ReturnSequence, Label] , @ins
end
end
end

View File

@ -7,7 +7,7 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end")
@compiler = compile_first_method( "if(@a) ; @a = 5 ; else; @a = 6 ; end;return")
@ins = @compiler.mom_instructions.next
end
@ -25,7 +25,7 @@ module Vool
end
def test_array
check_array [TruthCheck, Label, SlotLoad, Jump, Label ,
SlotLoad, Label, Label, ReturnSequence, Label], @ins
SlotLoad, Label, SlotLoad, ReturnJump,Label, ReturnSequence, Label], @ins
end
end
end

View File

@ -6,7 +6,7 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end")
@compiler = compile_first_method( "if(5.div4) ; @a = 6 ; else; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next
end
@ -23,7 +23,7 @@ module Vool
def test_array
check_array [MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck, Label ,
SlotLoad, Jump, Label, SlotLoad, Label ,
Label, ReturnSequence, Label] , @ins
SlotLoad, ReturnJump,Label, ReturnSequence, Label] , @ins
end
end

View File

@ -6,7 +6,7 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "while(@a) ; @a = 5 ; end")
@compiler = compile_first_method( "while(@a) ; @a = 5 ; end;return")
@ins = @compiler.mom_instructions.next
end
@ -21,7 +21,7 @@ module Vool
end
def test_array
check_array [Label, TruthCheck, SlotLoad, Jump, Label ,
Label, ReturnSequence, Label], @ins
SlotLoad, ReturnJump,Label, ReturnSequence, Label], @ins
end
end
end

View File

@ -7,7 +7,7 @@ module Vool
def setup
Parfait.boot!(Parfait.default_test_options)
@compiler = compile_first_method( "while(5.div4) ; 5.div4 ; end")
@compiler = compile_first_method( "while(5.div4) ; 5.div4 ; end;return")
@ins = @compiler.mom_instructions.next
end
@ -30,7 +30,8 @@ module Vool
def test_array
check_array [Label, MessageSetup, ArgumentTransfer, SimpleCall, TruthCheck ,
MessageSetup, ArgumentTransfer, SimpleCall, Jump, Label ,
Label, ReturnSequence, Label] , @ins
SlotLoad, ReturnJump,Label, ReturnSequence, Label ,Label ,
ReturnSequence, Label] , @ins
end
end