JavaCompilerCore/test/syntaxTree/NodeEqualTest.java
2014-03-14 16:34:25 +01:00

50 lines
1.2 KiB
Java

package syntaxTree;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import mycompiler.MyCompiler;
import mycompiler.MyCompilerAPI;
import mycompiler.SourceFile;
import mycompiler.SyntaxTreeNode;
import mycompiler.myparser.JavaParser.yyException;
import org.junit.Test;
import junit.framework.TestCase;
public class NodeEqualTest extends TestCase{
private static final String rootDirectory = System.getProperty("user.dir")+"/test/plugindevelopment/";
private static final String testFile = "";
@Test
public void test(){
String inferedSource = "";
MyCompilerAPI compiler = MyCompiler.getAPI();
SourceFile tree = null;
try {
tree = compiler.parse(new File(rootDirectory + testFile));
} catch (IOException | yyException e) {
e.printStackTrace();
fail();
}
}
private void recursivlyCheckEqual(SyntaxTreeNode node1, SyntaxTreeNode node2){
for(SyntaxTreeNode n1 : node1.getChildren()){
int matches = 0;
for(SyntaxTreeNode n2 : node2.getChildren()){
if(n2.equals(n1)){
matches++;
this.recursivlyCheckEqual(n1, n2);
}
}
assertTrue("Nur eines der Children darf gleich sein", matches == 1);
}
}
}