diff --git a/lib/parfait/indexed.rb b/lib/parfait/indexed.rb index abd41fa1..ed71ac26 100644 --- a/lib/parfait/indexed.rb +++ b/lib/parfait/indexed.rb @@ -166,7 +166,7 @@ module Parfait grow_to(index) end # start one higher than offset, which is where the length is - internal_object_set( index + 1 + offset, value) + internal_object_set( index + offset, value) end # set the value at index. @@ -176,7 +176,7 @@ module Parfait ret = nil if(index <= self.get_length) # start one higher than offset, which is where the length is - ret = internal_object_get(index + offset + 1) + ret = internal_object_get(index + offset ) end ret end diff --git a/lib/register/instructions/get_slot.rb b/lib/register/instructions/get_slot.rb index 2abc0a4b..a921178b 100644 --- a/lib/register/instructions/get_slot.rb +++ b/lib/register/instructions/get_slot.rb @@ -23,6 +23,7 @@ module Register @array = array @index = index @register = register + raise "index 0 " if index == 0 raise "not integer #{index}" unless index.is_a? Numeric raise "Not register #{register}" unless RegisterValue.look_like_reg(register) raise "Not register #{array}" unless RegisterValue.look_like_reg(array) diff --git a/test/parfait/test_message.rb b/test/parfait/test_message.rb index 56cca1b0..1cf75458 100644 --- a/test/parfait/test_message.rb +++ b/test/parfait/test_message.rb @@ -31,6 +31,10 @@ class TestMessage < MiniTest::Test @mess.push :name assert_equal 1 , @mess.internal_object_get(9) end + def test_get_internal + @mess.push :name + assert_equal :name , @mess.internal_object_get(10) + end def test_get index = @mess.push :name