use of ch.hsr.ifs.cdttesting.cdttest.comparison.ASTComparison.ComparisonResult in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class CommentRelation method equals.
public static ComparisonResult equals(CommentRelation left, CommentRelation right, EnumSet<ComparisonArg> args) {
if (right == null || left == null) {
return new ComparisonResult(ComparisonState.NO_COUNTERPART, ASTComparison.generateBasicComparisonResultAttributes(left == null ? null : left.comment, right == null ? null : right.comment, args));
}
ComparisonResult commentResult = ASTComparison.equals(left.comment, right.comment, ComparisonArg.emptySet());
ComparisonResult previousResult = ASTComparison.equals(left.previous, right.previous, ComparisonArg.emptySet());
ComparisonResult nextResult = ASTComparison.equals(left.next, right.next, ComparisonArg.emptySet());
ComparisonResult enclosingResult = ASTComparison.equals(left.enclosing, right.enclosing, ComparisonArg.emptySet());
if (commentResult.isUnequal() || previousResult.isUnequal() || nextResult.isUnequal() || enclosingResult.isUnequal()) {
return new ComparisonResult(ComparisonState.DIFFERENT_COMMENT, commentResult.attributes);
} else {
return new ComparisonResult(ComparisonState.EQUAL);
}
}
use of ch.hsr.ifs.cdttesting.cdttest.comparison.ASTComparison.ComparisonResult in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class ASTComparisonTest method assertDifferentAST.
private void assertDifferentAST() throws IOException, ParserException {
CharSequence[] sections = getContents(2);
IASTTranslationUnit first = parse(sections[0].toString(), ParserLanguage.CPP, true);
IASTTranslationUnit second = parse(sections[1].toString(), ParserLanguage.CPP, true);
ComparisonResult result = ASTComparison.equalsAST(first, second, EnumSet.of(ComparisonArg.COMPARE_COMMENTS, ComparisonArg.COMPARE_INCLUDE_DIRECTIVES));
assertTrue(result.state != ComparisonState.EQUAL);
}
use of ch.hsr.ifs.cdttesting.cdttest.comparison.ASTComparison.ComparisonResult in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class NodeComparisonVisitor method compareNodes.
protected ComparisonResult compareNodes() throws InterruptedException {
while (true) {
IASTNode expected = leftCollector.poll();
IASTNode actual = rightCollector.poll();
if (expected instanceof EOTNode && actual instanceof EOTNode)
break;
ComparisonResult result = ASTComparison.equals(expected, actual, args);
if (result.isUnequal()) {
leftCollector.abort();
rightCollector.abort();
return result;
}
}
return new ComparisonResult(ComparisonState.EQUAL);
}
use of ch.hsr.ifs.cdttesting.cdttest.comparison.ASTComparison.ComparisonResult in project ch.hsr.ifs.cdttesting by IFS-HSR.
the class NodeComparisonVisitor method compare.
public ComparisonResult compare() {
leftCollector.schedule();
rightCollector.schedule();
ComparisonResult result;
try {
result = compareNodes();
leftCollector.join();
rightCollector.join();
if (result.isUnequal()) {
return result;
} else if (compareComments) {
return commentsEqual();
} else {
return new ComparisonResult(ComparisonState.EQUAL);
}
} catch (InterruptedException e) {
StringPrintStream stream = StringPrintStream.createNew();
e.printStackTrace();
e.printStackTrace(stream);
return new ComparisonResult(ComparisonState.INTERRUPTED, new ComparisonAttribute(ComparisonAttrID.ACTUAL, e.getClass().getSimpleName(), stream.toString()));
}
}
Aggregations