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:
parent
50029711ff
commit
bd171d091a
@ -11,14 +11,14 @@ module Soml
|
||||
code = nil
|
||||
if( index = @method.has_arg(name))
|
||||
# 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
|
||||
index = @method.has_local( name )
|
||||
if(index)
|
||||
# TODO, check type @method.locals[index].type
|
||||
frame = use_reg(: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
|
||||
if( code )
|
||||
|
@ -35,7 +35,7 @@ module Soml
|
||||
val = process( arg)
|
||||
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)
|
||||
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
|
||||
end
|
||||
|
||||
|
@ -15,7 +15,7 @@ module Soml
|
||||
# either an argument, so it's stored in message
|
||||
if( index = @method.has_arg(name))
|
||||
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
|
||||
else # or a local so it is in the frame
|
||||
index = @method.has_local( name )
|
||||
@ -23,7 +23,7 @@ module Soml
|
||||
frame = use_reg :Frame
|
||||
add_code Register.get_slot(statement , :message , :frame , frame )
|
||||
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
|
||||
end
|
||||
end
|
||||
|
@ -78,11 +78,11 @@ HERE
|
||||
end
|
||||
|
||||
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
|
||||
class Object
|
||||
int main(int bar)
|
||||
bar = 5
|
||||
int main(int blar)
|
||||
blar = 5
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@ -110,11 +110,11 @@ HERE
|
||||
|
||||
def test_arg_get
|
||||
# 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
|
||||
class Object
|
||||
int main(int bar)
|
||||
return bar
|
||||
int main(int balr)
|
||||
return balr
|
||||
end
|
||||
end
|
||||
HERE
|
||||
|
@ -17,7 +17,7 @@ class TestAttributes < MiniTest::Test
|
||||
end
|
||||
def test_message_name_nil
|
||||
last = @layout.instance_names.last
|
||||
assert_equal :name , last
|
||||
assert_equal :indexed_length , last
|
||||
assert_equal nil , @mess.name
|
||||
end
|
||||
def test_message_next_set
|
||||
|
@ -33,12 +33,12 @@ class TestLayout < MiniTest::Test
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def test_layout_length
|
||||
assert_equal 8 , @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.indexed_length , @mess.get_layout.inspect
|
||||
assert_equal 9 , @mess.get_layout.internal_object_get(4)
|
||||
end
|
||||
|
||||
def test_layout_length_index
|
||||
@ -56,7 +56,7 @@ class TestLayout < MiniTest::Test
|
||||
def test_no_index_below_1
|
||||
layout = @mess.get_layout
|
||||
names = layout.instance_names
|
||||
assert_equal 8 , names.get_length , names.inspect
|
||||
assert_equal 9 , names.get_length , names.inspect
|
||||
names.each do |n|
|
||||
assert layout.variable_index(n) >= 1
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user