fix mom and vool after cc changes

This commit is contained in:
Torsten Rüger 2019-08-23 10:21:22 +03:00
parent ec1e8c8f3a
commit 5e44e9caaf
16 changed files with 50 additions and 64 deletions

View File

@ -7,9 +7,7 @@ module Risc
def setup
super
@input = "local = arg; return local"
@expect =[ SlotToReg, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #4
RegToSlot, Branch] #9
@expect = [SlotToReg, RegToSlot, SlotToReg, RegToSlot, Branch] #4
end
def test_local_assign_instructions
assert_nil msg = check_nil , msg
@ -26,8 +24,8 @@ module Risc
end
def test_load_frame_from_message
produced = produce_body
assert_equal :r3 , produced.next(2).array.symbol , produced.next.to_rxf[0..200]
assert_equal 3 , produced.next.index , produced.next.to_rxf[0..200]
assert_equal 16 , produced.next.index , produced.next.to_rxf[0..200]
assert_equal :r0 , produced.next(2).array.symbol
end
end
end

View File

@ -7,7 +7,7 @@ module Risc
def setup
super
@input = "r = false;return"
@expect = [LoadConstant,SlotToReg, RegToSlot,LoadConstant, RegToSlot, Branch]
@expect = [LoadConstant, RegToSlot,LoadConstant, RegToSlot, Branch]
end
def test_local_assign_instructions
assert_nil msg = check_nil , msg
@ -21,12 +21,12 @@ module Risc
def test_frame_load
produced = produce_body
assert_equal :Message , produced.next(1).array.type.class_name
assert_equal 3 , produced.next(1).index # 3 is frame
assert_equal 16 , produced.next(1).index # 3 is frame
end
def test_value_load
produced = produce_body
assert_equal produced.next(2).register , produced.register
assert_equal 1 , produced.next(2).index #type == 0 , r == 1
assert_equal 16 , produced.next(1).index #type == 0 , r == 16
end
end

View File

@ -7,7 +7,7 @@ module Risc
def setup
super
@input = "r = 5;return"
@expect = [LoadConstant,SlotToReg, RegToSlot, LoadConstant, RegToSlot, Branch]
@expect = [LoadConstant, RegToSlot, LoadConstant, RegToSlot, Branch]
end
def test_local_assign_instructions
assert_nil msg = check_nil , msg
@ -21,12 +21,11 @@ module Risc
def test_frame_load
produced = produce_body
assert_equal :Message , produced.next(1).array.type.class_name
assert_equal 3 , produced.next(1).index # 4 is frame
assert_equal 16 , produced.next(1).index # 4 is frame
end
def test_value_load
produced = produce_body
assert_equal produced.next(2).register , produced.register
assert_equal 1 , produced.next(2).index #type == 1 , r == 2
assert_equal produced.next(1).register , produced.register
end
end

View File

@ -7,8 +7,8 @@ module Risc
def setup
super
@input = "@ivar = 5 ; r = @ivar;return"
@expect = [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
RegToSlot, LoadConstant, RegToSlot, Branch]
@expect = [LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, #4
RegToSlot, LoadConstant, RegToSlot, Branch] #9
end
def test_local_assign_instructions
assert_nil msg = check_nil , msg

View File

@ -7,11 +7,11 @@ module Risc
def setup
super
@input = "r = 5.div4;return"
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot,
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg,
FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, Branch]
@expect = [LoadConstant, LoadConstant, SlotToReg, SlotToReg, RegToSlot, #4
RegToSlot, RegToSlot, RegToSlot, LoadConstant, SlotToReg, #9
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #14
FunctionCall, Label, SlotToReg, RegToSlot, LoadConstant, #19
RegToSlot, Branch] #2
end
def test_local_assign_instructions
assert_nil msg = check_nil , msg

View File

@ -7,7 +7,7 @@ module Risc
def setup
super
@input = as_block("a = 5")
@expect = [LoadConstant, SlotToReg, RegToSlot]
@expect = [LoadConstant, RegToSlot]
end
def test_send_instructions
assert_nil msg = check_nil(:main_block) , msg

View File

@ -7,11 +7,11 @@ module Risc
def setup
super
@input = as_block("return 5")
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, LoadConstant, #4
SlotToReg, SlotToReg, RegToSlot, RegToSlot, RegToSlot, #9
RegToSlot, SlotToReg, SlotToReg, RegToSlot, LoadConstant, #14
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, #19
SlotToReg, FunctionCall, Label] #24
@expect = [LoadConstant, RegToSlot, LoadConstant, LoadConstant, SlotToReg, #4
SlotToReg, RegToSlot, RegToSlot, RegToSlot, RegToSlot, #9
SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, #14
RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg, #19
FunctionCall, Label] #24
end
def test_send_instructions
@ -28,12 +28,12 @@ module Risc
assert_equal 5 , produced.constant.value
end
def test_load_next_message
produced = produce_body.next(4)
produced = produce_body.next(3)
assert_load( produced , Parfait::Factory)
assert_equal "Message_Type" , produced.constant.for_type.name
end
def test_load_block
produced = produce_body.next(14)
produced = produce_body.next(13)
assert_load( produced , Parfait::Block)
assert_equal :main_block , produced.constant.name
end
@ -43,12 +43,12 @@ module Risc
assert produced.constant.name.start_with?("continue_")
end
def test_function_call
produced = produce_body.next(21)
produced = produce_body.next(20)
assert_equal FunctionCall , produced.class
assert_equal :main , produced.method.name
end
def test_check_continue
produced = produce_body.next(23)
produced = produce_body.next(22)
assert_equal Label , produced.class
# assert produced.name.start_with?("continue_") , produced.name
end

View File

@ -15,7 +15,7 @@ module Parfait
def test_message_name_nil
last = @type.names.last
assert_equal :arg6 , last , @type.names.inspect
assert_equal :local15 , last , @type.names.inspect
assert_nil @mess.method
end
def test_message_next_set

View File

@ -10,23 +10,31 @@ module Parfait
def test_args_start
assert_equal 8 , Message.args_start_at
end
def test_locals_start
assert_equal 15 , Message.locals_start_at
end
def test_length
assert_equal 15 , @mess.get_type.instance_length , @mess.get_type.inspect
assert_equal 31 , @mess.get_type.instance_length , @mess.get_type.inspect
end
def test_attribute_set
@mess.set_receiver( 55 ) # 55 is not parfait, hance not actually allowed
assert_equal 55 , @mess.receiver
end
def test_indexed
def test_indexed_arg
assert_equal 8 , @mess.get_type.variable_index(:arguments_given)
assert_equal 9 , @mess.get_type.variable_index(:arg1)
assert_equal 13 , @mess.get_type.variable_index(:arg5)
end
def test_indexed_local
assert_equal 15 , @mess.get_type.variable_index(:locals_used)
assert_equal 16 , @mess.get_type.variable_index(:local1)
assert_equal 30 , @mess.get_type.variable_index(:local15)
end
def test_next_message
assert_equal Message , @mess.next_message.class
end
def test_locals
assert_equal NamedList , @mess.frame.class
assert_equal Integer , @mess.locals_used.class
end
def test_arguments
assert_equal Integer , @mess.arguments_given.class

View File

@ -3,18 +3,6 @@ require_relative "helper"
module Parfait
class TestNamedLists < ParfaitTest
def setup
super
@named_list = @space.get_next_for(:Message).frame
@type = @named_list.get_type
end
def test_named_list_get_type
assert_equal Type , @type.class
assert @type.names
assert @named_list.get_instance_variables
end
def test_new
list = NamedList.new
assert list.get_type

View File

@ -198,7 +198,7 @@ module Parfait
count = 0
while(mess)
count += 1
assert mess.frame
assert mess.locals_used
mess = mess.next_message
end
assert_equal 1014, count

View File

@ -22,7 +22,7 @@ module Parfait
def test_length
assert @mess
assert @mess.get_type
assert_equal 15 , @mess.get_type.instance_length , @mess.get_type.inspect
assert_equal 31 , @mess.get_type.instance_length , @mess.get_type.inspect
end
def test_names
@ -33,7 +33,7 @@ module Parfait
end
def test_type_length
assert_equal 15 , @mess.get_type.instance_length , @mess.get_type.inspect
assert_equal 31 , @mess.get_type.instance_length , @mess.get_type.inspect
end
def test_type_length_index
@ -45,7 +45,7 @@ module Parfait
def test_no_index_below_0
type = @mess.get_type
names = type.names
assert_equal 15 , names.get_length , names.inspect
assert_equal 31 , names.get_length , names.inspect
names.each do |n|
assert type.variable_index(n) >= 0
end

View File

@ -18,7 +18,7 @@ module VoolBlocks
assert_equal :message , @ins.left.known_object
end
def test_slots_left
assert_equal [:frame , :local] , @ins.left.slots
assert_equal [:local1] , @ins.left.slots
end
def test_slot_assigns_something
assert @ins.right
@ -38,7 +38,7 @@ module VoolBlocks
assert_equal Mom::SlotLoad , @ins.class , @ins
end
def test_slots_left
assert_equal [:frame, :local] , @ins.left.slots
assert_equal [:local1] , @ins.left.slots
end
def test_slots_right
assert_equal [:receiver, :a] , @ins.right.slots

View File

@ -14,9 +14,8 @@ module Vool
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
assert_equal :local1 , load.right.slots[0] , load
assert_equal :type , load.right.slots[1] , load
end
def test_check_resolve_call
assert_equal ResolveMethod , @ins.next(3).class , @ins

View File

@ -19,11 +19,8 @@ module Vool
def test_slot_starts_at_message
assert_equal :message , @ins.left.known_object
end
def test_slot_gets_self
assert_equal :frame , @ins.left.slots[0]
end
def test_slot_assigns_to_local
assert_equal :local , @ins.left.slots[-1]
def test_slot_gets_local
assert_equal :local1 , @ins.left.slots[0]
end
def test_slot_assigns_something
assert @ins.right

View File

@ -22,11 +22,8 @@ module Vool
def test_slot_starts_at_message
assert_equal :message , @ins.left.known_object
end
def test_slot_gets_frame
assert_equal :frame , @ins.left.slots[0]
end
def test_slot_assigns_to_local
assert_equal :a , @ins.left.slots[-1]
def test_slot_gets_local
assert_equal :local1 , @ins.left.slots[0]
end
def test_slot_assigns_something
assert @ins.right