to_s for parfait list
This commit is contained in:
parent
e430701645
commit
0ebb8e31c6
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user