wwu-pi / muggl

A Symbolic ATCG
GNU General Public License v3.0
2 stars 1 forks source link

Failing test case generated when swapping the elements of an array #5

Open manuelmontenegro opened 10 years ago

manuelmontenegro commented 10 years ago

Commit id: 8498b7d

public int simpleArraySwap(int[] array) {
   swap array[0] and array[1]
   if (array[0] > array[1]) return 1;
   return 0;
}

This generates a test case (also uploaded) that passes the array {0,-1} to the function, and it expects to return 1, while it actually returns 0.

manuelmontenegro commented 10 years ago

It seems that whenever a symbolic array is initialized, an alias of it is passed to the Method.setGeneratedValue() method, but then the same array is modified, so when we need to retrieve this array via Method.getGeneratedValues() it returns the symbolic array [array[1], array[0]] instead of [array[0], array[1]].

This leads the test generation module to create the array {0,-1} instead of {-1,0}, which is what corresponds to the solution found.

I have worked around it (4f19bb6) by cloning the ModfieableArrayRef passed to Method.setGeneratedValue(), so the subsequent changes to the array are not reflected in the symbolic parameters of the method. This solves the simple example shown above, but I do not know it the modification will break something else in Muggl.