From 701b0bc0112555971836a2cf90043a6e0ce2d74b Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 17 May 2015 14:44:48 +0300 Subject: [PATCH] fix object grow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and write a test (and another one …) --- lib/parfait.rb | 3 +-- test/parfait/test_all.rb | 1 + test/parfait/test_object.rb | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/parfait.rb b/lib/parfait.rb index 16144039..b0bc5f48 100644 --- a/lib/parfait.rb +++ b/lib/parfait.rb @@ -58,8 +58,7 @@ module Parfait old_length = internal_object_length() while( old_length < length ) internal_object_set( old_length + 1, nil) - - + old_length = old_length + 1 end end end diff --git a/test/parfait/test_all.rb b/test/parfait/test_all.rb index 3576a7e1..c07d1f5d 100644 --- a/test/parfait/test_all.rb +++ b/test/parfait/test_all.rb @@ -1,3 +1,4 @@ +require_relative "test_object" require_relative "test_list" require_relative "test_word" require_relative "test_dictionary" diff --git a/test/parfait/test_object.rb b/test/parfait/test_object.rb index 52e32272..031aa232 100644 --- a/test/parfait/test_object.rb +++ b/test/parfait/test_object.rb @@ -10,6 +10,11 @@ class TestObject < MiniTest::Test assert_equal 0 , @object.internal_object_length end + def test_list_grow + @object.internal_object_grow( 2 ) + assert_equal 2 , @object.internal_object_length + end + def test_empty_list_doesnt_return assert_equal nil , @object.internal_object_get(3) end