Project

General

Profile

Bug #13797 ยป Class bug_JP.rb

Test code showing normal and class cases - gggfx (James Pike), 08/10/2017 11:22 AM

 
class FdArray
def initialize(totalSize)
@data_array = Array.new(totalSize,[])
end
def addOn(location,data)
@data_array[location].push(data)
end
def write(location, data)
@data_array[location] = data
end
def read(location)
return @data_array[location]
end
def giveAll
return @data_array
end
end
#---------------------------------------------
# TEST NORMAL Array
#---------------------------------------------
testArray = [[],[]]
#These should put two items in the array (sub-array) in position 0
testArray[0]<<"test1"
testArray[0].push("test2")
print("0,0:",testArray[0][0])
print("0,1:",testArray[0][1])
print("\n\n TEST ARR :",testArray)
#Direct write
testArray[1][1]="x"
print("\n\n TEST ARR :",testArray)
#---------------------------------------------
# TEST CLASS ARRAY
#---------------------------------------------
fd = FdArray.new(10)
#This should 'push' one item data onto the subarray
fd.addOn(4,10)
fd.read(4)
print("\n\n FD ARRAY: \n",fd.giveAll)
    (1-1/1)