Parser tests angefügt

This commit is contained in:
JanUlrich 2014-03-17 20:05:12 +01:00
parent dbda805fa5
commit 75f9a74c44
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,3 @@
class FieldInitializationTest{
String var = "hallo";
}

View File

@ -0,0 +1,43 @@
package parser;
import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Vector;
import junit.framework.TestCase;
import mycompiler.MyCompiler;
import mycompiler.MyCompilerAPI;
import org.junit.Test;
/**
* Dieser Test prüft nur, ob .java-Dateien fehlerfrei geparst werden.
* Der dabei erstellte Syntaxbaum wird nicht kontrolliert.
* @author janulrich
*
*/
public class GeneralParserTest{
private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/";
@Test
public void run(){
Vector<String> filenames = new Vector<String>();
filenames.add("FieldInitializationTest.jav");
MyCompilerAPI compiler = MyCompiler.getAPI();
try{
for(String filename : filenames)
compiler.parse(new File(rootDirectory + filename));
}catch(Exception exc){
exc.printStackTrace();
fail();
}
assertTrue("Tests durchlaufen",filenames.size()>0);
}
}