Skip to content

Commit 9f6fc32

Browse files
committed
Enable MO31 when the constant is from a list
1 parent fa968e3 commit 9f6fc32

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

src/uniandes/tsdl/mutapk/MutAPK.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package uniandes.tsdl.mutapk;
22

3+
import java.io.BufferedWriter;
34
import java.io.File;
45
import java.io.FileInputStream;
6+
import java.io.FileWriter;
7+
import java.io.IOException;
58
import java.io.InputStreamReader;
69
import java.util.HashMap;
710
import java.util.List;
@@ -111,6 +114,7 @@ public static void runMutAPK(String[] args) throws Exception {
111114

112115
//3. Build MutationLocation List
113116
List<MutationLocation> mutationLocationList = MutationLocationListBuilder.buildList(locations);
117+
printLocationList(mutationLocationList, mutantsFolder, appName);
114118
System.out.println("Total Locations: "+mutationLocationList.size());
115119

116120
//3. Run mutation phase
@@ -124,4 +128,49 @@ public static void runMutAPK(String[] args) throws Exception {
124128

125129
}
126130

131+
private static void printLocationList(List<MutationLocation> mutationLocationList, String mutantsFolder, String appName) {
132+
133+
try {
134+
BufferedWriter writer = new BufferedWriter(
135+
new FileWriter(mutantsFolder + File.separator + appName + "-locations.json"));
136+
writer.write("{");
137+
writer.newLine();
138+
writer.flush();
139+
for (int i = 0; i < mutationLocationList.size(); i++) {
140+
MutationLocation temp = mutationLocationList.get(i);
141+
writer.write(" \""+(i+1)+"\":{");
142+
writer.newLine();
143+
writer.write(" \"mutationTypeID\":\""+temp.getType().getId()+"\",");
144+
writer.newLine();
145+
writer.write(" \"mutationTypeName\":\""+temp.getType().getName()+"\",");
146+
writer.newLine();
147+
writer.write(" \"filePath\":\""+temp.getFilePath()+"\",");
148+
writer.newLine();
149+
writer.write(" \"line\":\""+temp.getLine()+"\",");
150+
writer.newLine();
151+
writer.write(" \"startLine\":\""+temp.getStartLine()+"\",");
152+
writer.newLine();
153+
writer.write(" \"endLine\":\""+temp.getEndLine()+"\",");
154+
writer.newLine();
155+
writer.write(" \"startColumn\":\""+temp.getStartColumn()+"\",");
156+
writer.newLine();
157+
writer.write(" \"endColumn\":\""+temp.getEndColumn()+"\",");
158+
writer.newLine();
159+
writer.write(" \"length\":\""+temp.getLength()+"\"");
160+
writer.newLine();
161+
writer.write((i==mutationLocationList.size()-1)?" }":" },");
162+
writer.newLine();
163+
writer.flush();
164+
}
165+
writer.write("}");
166+
writer.newLine();
167+
writer.flush();
168+
writer.close();
169+
} catch (IOException e) {
170+
// TODO Auto-generated catch block
171+
e.printStackTrace();
172+
}
173+
174+
}
175+
127176
}

src/uniandes/tsdl/mutapk/operators/gui/android/InvalidIDFindView.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,17 @@ public boolean performMutation(MutationLocation location, BufferedWriter writer,
3434
linee = parent.getLine();
3535
}
3636
}
37+
// System.out.println(mutantIndex+" "+parent.toStringTree());
38+
// System.out.println(mutantIndex+" "+((CommonTree)parent.getParent().getChild(parent.getChildIndex()-1)).toStringTree());
39+
// System.out.println(mutantIndex+" "+((CommonTree)parent.getParent().getChild(parent.getChildIndex()-2)).toStringTree());
3740

38-
if (!isParam) {
41+
if (uncle != null && !isParam) {
3942
constVarName = uncle.getChild(1).getText();
4043
linee = uncle.getLine();
41-
}
44+
} else if (uncle == null) {
45+
constVarName = parent.getChild(1).getChild(1).getText();
46+
linee = parent.getLine();
47+
}
4248

4349

4450
List<String> newLines = new ArrayList<String>();

test/MutAPK-0.0.1.jar

11.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)