Quantcast
Channel: The Open Source Experience
Viewing all articles
Browse latest Browse all 10

Release 0.2 – Bug #1139

$
0
0

So sticking with Processing.js, I decided to work on bug #1139. After a bit of testing, I found that the reason the example below doesn’t work properly is because there is no constructor to handle ArrayList as a parameter.

ArrayList second = new ArrayList(first);

Because the constructor was expecting an int, it would take the object and create and array of the same size without taking the values. Using the “typeof” command, I could test the parameters and if the parameter was an object, create a copy of the array. 

if(typeof size === “object”){
var array = size.slice(0);
}else{
var array = new Array(0 | size);
}
Now what was left was to create some tests, I created an ArrayList test file because I could not find one and inputted some tests.

ArrayList first = new ArrayList();
first.add(“1″);
first.add(“2″);
first.add(“3″);
first.add(“4″);
first.add(“5″);

ArrayList second = new ArrayList();
second.add(“1″);
second.add(“2″);
second.add(“3″);
second.add(“4″);
second.add(“5″);

ArrayList third = new ArrayList(first);

_checkEqual(first, second);
_checkEqual(first, third);
_checkEqual(third, second);

Then I ran all the tests.

 



Viewing all articles
Browse latest Browse all 10

Trending Articles