check edges directions only in ControlFlowTest

This commit is contained in:
Svetlana Isakova
2014-03-05 15:26:22 +04:00
parent 547ee304b6
commit ab9e470ea9
2 changed files with 19 additions and 15 deletions
@@ -100,4 +100,22 @@ public abstract class AbstractControlFlowTest extends AbstractPseudocodeTest {
}
return Collections.singleton(natural).equals(new HashSet<Instruction>(actual));
}
@Override
protected void checkPseudocode(PseudocodeImpl pseudocode) {
//check edges directions
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));
}
}
}
}
}
@@ -122,21 +122,7 @@ public abstract class AbstractPseudocodeTest extends KotlinTestWithEnvironment {
JetTestUtils.assertEqualsToFile(expectedInstructionsFile, instructionDump.toString());
}
private void checkPseudocode(PseudocodeImpl pseudocode) {
//check edges directions
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));
}
}
}
protected void checkPseudocode(PseudocodeImpl pseudocode) {
}
private static String formatInstruction(Instruction instruction, int maxLength, Set<Instruction> remainedAfterPostProcessInstructions) {