fix tests for indexed messages and frames

index_length changes index a bit
but from now on changes to layouts should push the index automatically
just have to set the index while calling now
This commit is contained in:
Torsten Ruger 2015-10-27 16:05:50 +02:00
parent 50029711ff
commit bd171d091a
6 changed files with 16 additions and 16 deletions

View File

@ -11,14 +11,14 @@ module Soml
code = nil code = nil
if( index = @method.has_arg(name)) if( index = @method.has_arg(name))
# TODO, check type @method.arguments[index].type # TODO, check type @method.arguments[index].type
code = Register.set_slot(statement , v , :message , index + Parfait::Message.offset ) code = Register.set_slot(statement , v , :message , Parfait::Message.get_indexed(index) )
else # or a local so it is in the frame else # or a local so it is in the frame
index = @method.has_local( name ) index = @method.has_local( name )
if(index) if(index)
# TODO, check type @method.locals[index].type # TODO, check type @method.locals[index].type
frame = use_reg(:Frame) frame = use_reg(:Frame)
add_code Register.get_slot(statement , :message , :frame , frame ) add_code Register.get_slot(statement , :message , :frame , frame )
code = Register.set_slot(statement , v , frame , index + Parfait::Frame.offset ) code = Register.set_slot(statement , v , frame , Parfait::Frame.get_indexed(index) )
end end
end end
if( code ) if( code )

View File

@ -35,7 +35,7 @@ module Soml
val = process( arg) val = process( arg)
raise "Not register #{val}" unless val.is_a?(Register::RegisterValue) raise "Not register #{val}" unless val.is_a?(Register::RegisterValue)
# which we load int the new_message at the argument's index (the one comes from c index) # which we load int the new_message at the argument's index (the one comes from c index)
set = Register.set_slot( statement , val , :new_message , i + 1 + Parfait::Message.offset) set = Register.set_slot( statement , val , :new_message , Parfait::Message.get_indexed(i+1))
add_code set add_code set
end end

View File

@ -15,7 +15,7 @@ module Soml
# either an argument, so it's stored in message # either an argument, so it's stored in message
if( index = @method.has_arg(name)) if( index = @method.has_arg(name))
ret = use_reg @method.arguments[index].type ret = use_reg @method.arguments[index].type
add_code Register.get_slot(statement , :message , index + Parfait::Message.offset , ret ) add_code Register.get_slot(statement , :message , Parfait::Message.get_indexed(index), ret )
return ret return ret
else # or a local so it is in the frame else # or a local so it is in the frame
index = @method.has_local( name ) index = @method.has_local( name )
@ -23,7 +23,7 @@ module Soml
frame = use_reg :Frame frame = use_reg :Frame
add_code Register.get_slot(statement , :message , :frame , frame ) add_code Register.get_slot(statement , :message , :frame , frame )
ret = use_reg @method.locals[index].type ret = use_reg @method.locals[index].type
add_code Register.get_slot(statement , frame , index + Parfait::Frame.offset , ret ) add_code Register.get_slot(statement , frame , Parfait::Frame.get_indexed(index), ret )
return ret return ret
end end
end end

View File

@ -78,11 +78,11 @@ HERE
end end
def test_assign_arg def test_assign_arg
Register.machine.space.get_main.arguments.push Parfait::Variable.new(:Integer , :bar) Register.machine.space.get_main.arguments.push Parfait::Variable.new(:Integer , :blar)
@string_input = <<HERE @string_input = <<HERE
class Object class Object
int main(int bar) int main(int blar)
bar = 5 blar = 5
end end
end end
HERE HERE
@ -110,11 +110,11 @@ HERE
def test_arg_get def test_arg_get
# have to define bar externally, just because redefining main. Otherwise that would be automatic # have to define bar externally, just because redefining main. Otherwise that would be automatic
Register.machine.space.get_main.arguments.push Parfait::Variable.new(:Integer , :bar) Register.machine.space.get_main.arguments.push Parfait::Variable.new(:Integer , :balr)
@string_input = <<HERE @string_input = <<HERE
class Object class Object
int main(int bar) int main(int balr)
return bar return balr
end end
end end
HERE HERE

View File

@ -17,7 +17,7 @@ class TestAttributes < MiniTest::Test
end end
def test_message_name_nil def test_message_name_nil
last = @layout.instance_names.last last = @layout.instance_names.last
assert_equal :name , last assert_equal :indexed_length , last
assert_equal nil , @mess.name assert_equal nil , @mess.name
end end
def test_message_next_set def test_message_next_set

View File

@ -33,12 +33,12 @@ class TestLayout < MiniTest::Test
end end
def test_length def test_length
assert_equal 8 , @mess.get_layout.instance_length , @mess.get_layout.inspect assert_equal 9 , @mess.get_layout.instance_length , @mess.get_layout.inspect
end end
def test_layout_length def test_layout_length
assert_equal 8 , @mess.get_layout.indexed_length , @mess.get_layout.inspect assert_equal 9 , @mess.get_layout.indexed_length , @mess.get_layout.inspect
assert_equal 8 , @mess.get_layout.internal_object_get(4) assert_equal 9 , @mess.get_layout.internal_object_get(4)
end end
def test_layout_length_index def test_layout_length_index
@ -56,7 +56,7 @@ class TestLayout < MiniTest::Test
def test_no_index_below_1 def test_no_index_below_1
layout = @mess.get_layout layout = @mess.get_layout
names = layout.instance_names names = layout.instance_names
assert_equal 8 , names.get_length , names.inspect assert_equal 9 , names.get_length , names.inspect
names.each do |n| names.each do |n|
assert layout.variable_index(n) >= 1 assert layout.variable_index(n) >= 1
end end