void lineMatch(int index, Location loc, int javaLine, int xyzLine, int ratsLine) {
lineMatch(index, "Java", loc, javaLine);
lineMatch(index, "XYZ", loc, xyzLine);
lineMatch(index, "Rats", loc, ratsLine);
}
List listWith(String s1) {
List result = new ArrayList();
result.add(s1); return result;
}
List listWith(String s1, String s2) {
List result = new ArrayList();
result.add(s1);
result.add(s2); return result;
}
/********** test core **********/
protectedvoid runTests() throws Exception { /* * Get to the top of main() * to determine targetClass
*/
BreakpointEvent bpe = startToMain("onion.pickle.Mangle");
targetClass = bpe.location().declaringType();
// ref type source name
String sourceName = targetClass.sourceName(); if (sourceName.equals("Mangle.xyz")) {
println("ref type sourceName: " + sourceName);
} else {
failure("FAIL: unexpected ref type sourceName - " + sourceName);
}
// ref type source names /paths
List sourceNames;
sourceNames = targetClass.sourceNames("Java"); if (sourceNames.equals(listWith("Mangle.java"))) {
println("ref type Java sourceNames: " + sourceNames);
} else {
failure("FAIL: unexpected ref type Java sourceNames - " +
sourceNames);
}
sourceNames = targetClass.sourceNames("XYZ"); if (sourceNames.equals(listWith("Mangle.xyz", "Incl.xyz"))) {
println("ref type XYZ sourceNames: " + sourceNames);
} else {
failure("FAIL: unexpected ref type XYZ sourceNames - " +
sourceNames);
}
sourceNames = targetClass.sourceNames(null); if (sourceNames.equals(listWith("Mangle.xyz", "Incl.xyz"))) {
println("ref type null sourceNames: " + sourceNames);
} else {
failure("FAIL: unexpected ref type null sourceNames - " +
sourceNames);
}
sourceNames = targetClass.sourceNames("Rats"); if (sourceNames.equals(listWith("Mangle.rats", "Incl.rats"))) {
println("ref type Rats sourceNames: " + sourceNames);
} else {
failure("FAIL: unexpected ref type Rats sourceNames - " +
sourceNames);
}
List sourcePaths;
sourcePaths = targetClass.sourcePaths("Java"); if (sourcePaths.equals(listWith(op + "Mangle.java"))) {
println("ref type Java sourcePaths: " + sourcePaths);
} else {
failure("FAIL: unexpected ref type Java sourcePaths - " +
sourcePaths);
}
sourcePaths = targetClass.sourcePaths("XYZ"); if (sourcePaths.equals(listWith("database14", op + "Incl.xyz"))) {
println("ref type XYZ sourcePaths: " + sourcePaths);
} else {
failure("FAIL: unexpected ref type XYZ sourcePaths - " +
sourcePaths);
}
sourcePaths = targetClass.sourcePaths(null); if (sourcePaths.equals(listWith("database14", op + "Incl.xyz"))) {
println("ref type null sourcePaths: " + sourcePaths);
} else {
failure("FAIL: unexpected ref type null sourcePaths - " +
sourcePaths);
}
sourcePaths = targetClass.sourcePaths("Rats"); if (sourcePaths.equals(listWith(op + "Mangle.rats", "bleep:bleep:Incl.rats"))) {
println("ref type Rats sourcePaths: " + sourcePaths);
} else {
failure("FAIL: unexpected ref type Rats sourcePaths - " +
sourcePaths);
}
Method main = findMethod(targetClass, "main", "([Ljava/lang/String;)V");
List allLines = main.allLineLocations();
List javaLines = main.allLineLocations("Java", null);
List bogusLines = main.allLineLocations("bogus", null);
List nullLines = main.allLineLocations(null, null);
List xyzLines = main.allLineLocations("XYZ", null);
List ratsLines = main.allLineLocations("Rats", null);
List tl = new ArrayList(allLines);
tl.removeAll(xyzLines); if (tl.isEmpty() && allLines.size() == xyzLines.size()) {
println("allLineLocations() is OK");
} else {
failure("FAIL: allLineLocations() wrong - " + allLines);
}
tl = new ArrayList(bogusLines);
tl.removeAll(xyzLines); if (tl.isEmpty() && bogusLines.size() == xyzLines.size()) {
println("allLineLocations(\"bogus\") is OK");
} else {
failure("FAIL: allLineLocations(\"bogus\") wrong - " + bogusLines);
}
tl = new ArrayList(nullLines);
tl.removeAll(xyzLines); if (tl.isEmpty() && nullLines.size() == xyzLines.size()) {
println("allLineLocations(null) is OK");
} else {
failure("FAIL: allLineLocations(null) wrong - " + nullLines);
}
if (!javaLines.get(0).equals(ratsLines.get(0))) {
failure("FAIL: locations should match - " + javaLines.get(0));
} if (javaLines.get(0).equals(xyzLines.get(0))) {
failure("FAIL: locations should not match - " +
javaLines.get(0));
} if (!javaLines.get(1).equals(ratsLines.get(1))) {
failure("FAIL: locations should match - " + javaLines.get(1));
} if (!javaLines.get(1).equals(xyzLines.get(0))) {
failure("FAIL: locations should match - " + javaLines.get(1));
} if (javaLines.get(2).equals(ratsLines.get(1))) {
failure("FAIL: locations should not match - " +
javaLines.get(1));
} if (xyzLines.contains(javaLines.get(0))) {
failure("FAIL: xyz locations should not match - " +
javaLines.get(0));
} if (xyzLines.contains(javaLines.get(2))) {
failure("FAIL: xyz locations should not match - " +
javaLines.get(2));
} if (xyzLines.contains(javaLines.get(6))) {
failure("FAIL: xyz locations should not match - " +
javaLines.get(6));
}
if (ratsLines.contains(javaLines.get(2))) {
failure("FAIL: rats locations should not match - " +
javaLines.get(2));
} if (ratsLines.contains(javaLines.get(4))) {
failure("FAIL: rats locations should not match - " +
javaLines.get(4));
} if (ratsLines.contains(javaLines.get(5))) {
failure("FAIL: rats locations should not match - " +
javaLines.get(5));
}
/* * resume the target listening for events
*/
listenUntilVMDisconnect();
/* * deal with results of test * if anything has called failure("foo") testFailed will be true
*/ if (!testFailed) {
println("MangleTest: passed");
} else { thrownew Exception("MangleTest: failed");
}
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.