diff --git a/lib/parfait/list.rb b/lib/parfait/list.rb index 0a692c76..33c80412 100644 --- a/lib/parfait/list.rb +++ b/lib/parfait/list.rb @@ -20,7 +20,7 @@ module Parfait super self.indexed_length = 0 end - + def data_length self.class.data_length end @@ -253,6 +253,15 @@ module Parfait list end + def to_s + res = "[" + each do |item| + res = res + item.to_s + res = res + " ," + end + res = res + " ]" + return res + end def to_a array = [] index = 0 diff --git a/lib/parfait/type.rb b/lib/parfait/type.rb index 78a0595a..b659c734 100644 --- a/lib/parfait/type.rb +++ b/lib/parfait/type.rb @@ -153,7 +153,7 @@ module Parfait # resolve according to normal oo logic, ie look up in superclass if not present # NOTE: this will probably not work in future as the code for the superclass - # method, being bound to t adifferent type, will assume that types (not the run-time + # method, being bound to a different type, will assume that types (not the run-time # actual types) layout. Either need to enforce some c++ style upwards compatibility (buuh) # or copy the methods and recompile them for the actual type. (maybe still later dynamically) # But for now we walk up, as it should really just be to object diff --git a/test/parfait/test_list1.rb b/test/parfait/test_list1.rb index 09fa3d4f..3b4d0e7c 100644 --- a/test/parfait/test_list1.rb +++ b/test/parfait/test_list1.rb @@ -70,6 +70,9 @@ module Parfait end assert_equal 2 , counter end + def test_to_s + assert_equal "[one ,two ,three , ]" , @list.to_s + end def test_to_a arr = @list.to_a assert_equal Array , arr.class