Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
manuelmontenegro opened this issue Sep 3, 2014 · 1 comment

Comments

@manuelmontenegro
Copy link
Contributor

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 added a commit that referenced this issue Sep 18, 2014
@manuelmontenegro
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant