refactoring: extracted 'checkPseudocode'
This commit is contained in:
@@ -115,9 +115,16 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
File expectedInstructionsFile = JetTestUtils.replaceExtension(file, "instructions");
|
||||||
|
JetTestUtils.assertEqualsToFile(expectedInstructionsFile, instructionDump.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkPseudocode(PseudocodeImpl pseudocode) {
|
||||||
//check edges directions
|
//check edges directions
|
||||||
Collection<Instruction> instructions = ((PseudocodeImpl)pseudocode).getAllInstructions();
|
Collection<Instruction> instructions = pseudocode.getAllInstructions();
|
||||||
for (Instruction instruction : instructions) {
|
for (Instruction instruction : instructions) {
|
||||||
if (!((InstructionImpl)instruction).isDead()) {
|
if (!((InstructionImpl)instruction).isDead()) {
|
||||||
for (Instruction nextInstruction : instruction.getNextInstructions()) {
|
for (Instruction nextInstruction : instruction.getNextInstructions()) {
|
||||||
@@ -132,15 +139,6 @@ public abstract class AbstractControlFlowTest extends KotlinTestWithEnvironment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File expectedInstructionsFile = JetTestUtils.replaceExtension(file, "instructions");
|
|
||||||
JetTestUtils.assertEqualsToFile(expectedInstructionsFile, instructionDump.toString());
|
|
||||||
|
|
||||||
// StringBuilder graphDump = new StringBuilder();
|
|
||||||
// for (Pseudocode pseudocode : pseudocodes) {
|
|
||||||
// topOrderDump(pseudocode.)
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String formatInstruction(Instruction instruction, int maxLength, Set<Instruction> remainedAfterPostProcessInstructions) {
|
private static String formatInstruction(Instruction instruction, int maxLength, Set<Instruction> remainedAfterPostProcessInstructions) {
|
||||||
String[] parts = instruction.toString().split("\n");
|
String[] parts = instruction.toString().split("\n");
|
||||||
boolean isRemovedThroughPostProcess = !remainedAfterPostProcessInstructions.contains(instruction);
|
boolean isRemovedThroughPostProcess = !remainedAfterPostProcessInstructions.contains(instruction);
|
||||||
|
|||||||
Reference in New Issue
Block a user