fix all tests from removing the receiver load

This commit is contained in:
Torsten Ruger 2018-03-20 23:31:42 +05:30
parent 48485477c2
commit d9ce295b89
14 changed files with 47 additions and 44 deletions

View File

@ -7,8 +7,8 @@ module Risc
def setup def setup
super super
@input = "r = 5.mod4" @input = "r = 5.mod4"
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, Label , @expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, SlotToReg ,
SlotToReg, SlotToReg, RegToSlot] SlotToReg, RegToSlot]
end end
def test_local_assign_instructions def test_local_assign_instructions
assert_nil msg = check_nil , msg assert_nil msg = check_nil , msg

View File

@ -51,7 +51,11 @@ module MomCompile
res << is.class.name.split("::").last res << is.class.name.split("::").last
is = is.next is = is.next
end end
"[#{res.join(',')}]" ret = ""
res.to_s.split(",").each_slice(6).each do |line|
ret += " " + line.join(",") + " ,\n"
end
ret.gsub('"' , '')
end end
end end

View File

@ -8,27 +8,27 @@ 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 4 , @ins.length , @ins assert_equal 3 , @ins.length , @ins
end end
def test_receiver_move_class def test_receiver_move_class
assert_equal Mom::ArgumentTransfer, @ins.next(2).class assert_equal Mom::ArgumentTransfer, @ins.next(1).class
end end
def test_receiver_move def test_receiver_move
assert_equal :receiver, @ins.next(1).left.slots[1] assert_equal Mom::SlotDefinition, @ins.next.receiver.class
end end
def test_receiver def test_receiver
type , value = receiver type , value = receiver
assert_equal type, @ins.next.right.known_object.class assert_equal type, @ins.next.receiver.known_object.class
assert_equal value, @ins.next.right.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(3).class assert_equal Mom::SimpleCall, @ins.next(2).class
end end
def test_call_has_method def test_call_has_method
assert_equal Parfait::TypedMethod, @ins.next(3).method.class assert_equal Parfait::TypedMethod, @ins.next(2).method.class
end end
def test_array def test_array
check_array [Mom::MessageSetup,Mom::SlotLoad,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins check_array [Mom::MessageSetup,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
end end
end end
end end

View File

@ -19,14 +19,14 @@ module Vool
assert_equal :type , load.right.slots[1] , load assert_equal :type , load.right.slots[1] , load
end end
def test_check_resolve_call def test_check_resolve_call
assert_equal SimpleCall , @ins.next(6).class , @ins assert_equal SimpleCall , @ins.next(5).class , @ins
end end
def test_dynamic_call_last def test_dynamic_call_last
assert_equal DynamicCall , @ins.last.class , @ins assert_equal DynamicCall , @ins.last.class , @ins
end end
def test_array def test_array
check_array [SlotLoad,NotSameCheck,SlotLoad,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,SlotLoad,MessageSetup,SlotLoad,ArgumentTransfer,DynamicCall] , @ins check_array [SlotLoad,NotSameCheck,SlotLoad,MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,MessageSetup,ArgumentTransfer,DynamicCall] , @ins
end end
end end

View File

@ -14,22 +14,20 @@ module Vool
def setup def setup
do_setup("self.get_internal_word(0)") do_setup("self.get_internal_word(0)")
end end
def test_receiver def test_receiver
assert_equal SlotDefinition, @ins.next.right.class assert_equal SlotDefinition, @ins.next.receiver.class
end end
def test_arg_one def test_arg_one
assert_equal SlotLoad, @ins.next(2).arguments[0].class assert_equal SlotLoad, @ins.next(1).arguments[0].class
end end
def test_call_two def test_call_two
assert_equal SimpleCall, @ins.next(3).class assert_equal SimpleCall, @ins.next(2).class
end end
def test_call_has_method def test_call_has_method
assert_equal Parfait::TypedMethod, @ins.next(3).method.class assert_equal Parfait::TypedMethod, @ins.next(2).method.class
end end
def test_call_has_right_method def test_call_has_right_method
assert_equal :get_internal_word, @ins.next(3).method.name assert_equal :get_internal_word, @ins.next(2).method.name
end end
end end
class TestSendSelfImplicitMom < TestSendSelfMom class TestSendSelfImplicitMom < TestSendSelfMom

View File

@ -14,7 +14,7 @@ module Vool
[Mom::IntegerConstant , 5] [Mom::IntegerConstant , 5]
end end
def test_call_has_right_method def test_call_has_right_method
assert_equal :mod4, @ins.next(3).method.name assert_equal :mod4, @ins.next(2).method.name
end end
end end

View File

@ -15,15 +15,15 @@ module Vool
[Mom::IntegerConstant , 5] [Mom::IntegerConstant , 5]
end end
def test_args_two_move def test_args_two_move
assert_equal :next_message, @ins.next(2).arguments[1].left.slots[0] assert_equal :next_message, @ins.next(1).arguments[1].left.slots[0]
assert_equal :arguments, @ins.next(2).arguments[1].left.slots[1] assert_equal :arguments, @ins.next(1).arguments[1].left.slots[1]
end end
def test_args_two_str def test_args_two_str
assert_equal Mom::IntegerConstant, @ins.next(2).arguments[1].right.known_object.class assert_equal Mom::IntegerConstant, @ins.next(1).arguments[1].right.known_object.class
assert_equal 2, @ins.next(2).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::SlotLoad,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins check_array [Mom::MessageSetup,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
end end
end end
end end

View File

@ -15,15 +15,12 @@ module Vool
end end
def test_args_one_move def test_args_one_move
assert_equal :next_message, @ins.next.next.arguments[0].left.slots[0] assert_equal :next_message, @ins.next.arguments[0].left.slots[0]
assert_equal :arguments, @ins.next.next.arguments[0].left.slots[1] assert_equal :arguments, @ins.next.arguments[0].left.slots[1]
end end
def test_args_one_str def test_args_one_str
assert_equal Mom::IntegerConstant, @ins.next.next.arguments[0].right.known_object.class assert_equal Mom::IntegerConstant, @ins.next.arguments[0].right.known_object.class
assert_equal 1, @ins.next.next.arguments[0].right.known_object.value assert_equal 1, @ins.next.arguments[0].right.known_object.value
end
def test_array
check_array [Mom::MessageSetup,Mom::SlotLoad,Mom::ArgumentTransfer,Mom::SimpleCall] , @ins
end end
end end
end end

View File

@ -12,16 +12,19 @@ module Vool
end end
def test_condition def test_condition
assert_equal TruthCheck , @ins.next(12).class assert_equal TruthCheck , @ins.next(10).class
end end
def test_condition_is_slot def test_condition_is_slot
assert_equal SlotDefinition , @ins.next(12).condition.class , @ins assert_equal SlotDefinition , @ins.next(10).condition.class , @ins
end end
def test_hoisted_dynamic_call def test_hoisted_dynamic_call
assert_equal DynamicCall , @ins.next(10).class assert_equal DynamicCall , @ins.next(8).class
end end
def test_array def test_array
check_array [NotSameCheck,SlotLoad,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,SlotLoad,MessageSetup,SlotLoad,ArgumentTransfer,DynamicCall,SlotLoad,TruthCheck,Label,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,Jump,Label,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,Label], @ins check_array [NotSameCheck, SlotLoad, MessageSetup, ArgumentTransfer, SimpleCall, SlotLoad ,
MessageSetup, ArgumentTransfer, DynamicCall, SlotLoad, TruthCheck, Label ,
MessageSetup, ArgumentTransfer, SimpleCall, Jump, Label, MessageSetup ,
ArgumentTransfer, SimpleCall, Label] , @ins
end end
end end

View File

@ -24,7 +24,7 @@ module Vool
assert_equal Label , @ins.last.class , @ins assert_equal Label , @ins.last.class , @ins
end end
def test_array def test_array
check_array [TruthCheck,Label,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,Label], @ins check_array [TruthCheck,Label,MessageSetup,ArgumentTransfer,SimpleCall,Label], @ins
end end
end end
end end

View File

@ -24,7 +24,8 @@ module Vool
assert_equal Label , @ins.last.class , @ins assert_equal Label , @ins.last.class , @ins
end end
def test_array def test_array
check_array [TruthCheck,Label,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,Jump,Label,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,Label], @ins check_array [TruthCheck, Label, MessageSetup, ArgumentTransfer, SimpleCall, Jump ,
Label, MessageSetup, ArgumentTransfer, SimpleCall, Label] , @ins
end end
end end
end end

View File

@ -51,7 +51,7 @@ module Vool
assert_equal ReturnSequence , @ins.last.class assert_equal ReturnSequence , @ins.last.class
end end
def test_array def test_array
check_array [MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,SlotLoad,SlotLoad,ReturnSequence] , @ins check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,SlotLoad,ReturnSequence] , @ins
end end
end end
end end

View File

@ -12,16 +12,16 @@ module Vool
end end
def test_condition_compiles_to_check def test_condition_compiles_to_check
assert_equal TruthCheck , @ins.next(6).class assert_equal TruthCheck , @ins.next(5).class
end end
def test_condition_is_slot def test_condition_is_slot
assert_equal SlotDefinition , @ins.next(6).condition.class , @ins assert_equal SlotDefinition , @ins.next(5).condition.class , @ins
end end
def test_hoisetd def test_hoisetd
assert_equal MessageSetup , @ins.class assert_equal MessageSetup , @ins.class
end end
def test_array def test_array
check_array [MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,SlotLoad,Label,TruthCheck,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,Jump,Label] , @ins check_array [MessageSetup,ArgumentTransfer,SimpleCall,SlotLoad,Label,TruthCheck,MessageSetup,ArgumentTransfer,SimpleCall,Jump,Label] , @ins
end end
end end

View File

@ -21,7 +21,7 @@ module Vool
assert_equal SlotDefinition , @ins.next.condition.class , @ins assert_equal SlotDefinition , @ins.next.condition.class , @ins
end end
def test_array def test_array
check_array [Label,TruthCheck,MessageSetup,SlotLoad,ArgumentTransfer,SimpleCall,Jump,Label] , @ins check_array [Label,TruthCheck,MessageSetup,ArgumentTransfer,SimpleCall,Jump,Label] , @ins
end end
end end
end end