refactoring: extracted 'checkPseudocode'
This commit is contained in:
@@ -115,30 +115,28 @@ public abstract class AbstractControlFlowTest extends KotlinTestWithEnvironment
|
|||||||
instructionDump.append("\n---------------------\n");
|
instructionDump.append("\n---------------------\n");
|
||||||
dumpInstructions((PseudocodeImpl) pseudocode, instructionDump);
|
dumpInstructions((PseudocodeImpl) pseudocode, instructionDump);
|
||||||
instructionDump.append("=====================\n");
|
instructionDump.append("=====================\n");
|
||||||
|
checkPseudocode((PseudocodeImpl) pseudocode);
|
||||||
//check edges directions
|
|
||||||
Collection<Instruction> instructions = ((PseudocodeImpl)pseudocode).getAllInstructions();
|
|
||||||
for (Instruction instruction : instructions) {
|
|
||||||
if (!((InstructionImpl)instruction).isDead()) {
|
|
||||||
for (Instruction nextInstruction : instruction.getNextInstructions()) {
|
|
||||||
assertTrue("instruction '" + instruction + "' has '" + nextInstruction + "' among next instructions list, but not vice versa",
|
|
||||||
nextInstruction.getPreviousInstructions().contains(instruction));
|
|
||||||
}
|
|
||||||
for (Instruction prevInstruction : instruction.getPreviousInstructions()) {
|
|
||||||
assertTrue("instruction '" + instruction + "' has '" + prevInstruction + "' among previous instructions list, but not vice versa",
|
|
||||||
prevInstruction.getNextInstructions().contains(instruction));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File expectedInstructionsFile = JetTestUtils.replaceExtension(file, "instructions");
|
File expectedInstructionsFile = JetTestUtils.replaceExtension(file, "instructions");
|
||||||
JetTestUtils.assertEqualsToFile(expectedInstructionsFile, instructionDump.toString());
|
JetTestUtils.assertEqualsToFile(expectedInstructionsFile, instructionDump.toString());
|
||||||
|
}
|
||||||
|
|
||||||
// StringBuilder graphDump = new StringBuilder();
|
private void checkPseudocode(PseudocodeImpl pseudocode) {
|
||||||
// for (Pseudocode pseudocode : pseudocodes) {
|
//check edges directions
|
||||||
// topOrderDump(pseudocode.)
|
Collection<Instruction> instructions = pseudocode.getAllInstructions();
|
||||||
// }
|
for (Instruction instruction : instructions) {
|
||||||
|
if (!((InstructionImpl)instruction).isDead()) {
|
||||||
|
for (Instruction nextInstruction : instruction.getNextInstructions()) {
|
||||||
|
assertTrue("instruction '" + instruction + "' has '" + nextInstruction + "' among next instructions list, but not vice versa",
|
||||||
|
nextInstruction.getPreviousInstructions().contains(instruction));
|
||||||
|
}
|
||||||
|
for (Instruction prevInstruction : instruction.getPreviousInstructions()) {
|
||||||
|
assertTrue("instruction '" + instruction + "' has '" + prevInstruction + "' among previous instructions list, but not vice versa",
|
||||||
|
prevInstruction.getNextInstructions().contains(instruction));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String formatInstruction(Instruction instruction, int maxLength, Set<Instruction> remainedAfterPostProcessInstructions) {
|
private static String formatInstruction(Instruction instruction, int maxLength, Set<Instruction> remainedAfterPostProcessInstructions) {
|
||||||
|
|||||||
Reference in New Issue
Block a user