From b0ef4aecd6c00824227643575b06bdf27662915c Mon Sep 17 00:00:00 2001 From: sebastian Date: Tue, 28 Mar 2017 00:46:21 +0200 Subject: [PATCH] =?UTF-8?q?Neuen=20Test=20f=C3=BCr=20new=20Statement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .classpath | 4 +- .../SyntaxTreeGenerator.java | 2 +- test/strucTypes/GeneralParserTest.java | 16 +++-- test/strucTypes/GeneralParserTest_Main.java | 70 +++++++++++++++++++ test/strucTypes/Main.jav | 6 ++ 5 files changed, 88 insertions(+), 10 deletions(-) create mode 100644 test/strucTypes/GeneralParserTest_Main.java create mode 100644 test/strucTypes/Main.jav diff --git a/.classpath b/.classpath index 0c07ce08..119bcfc0 100644 --- a/.classpath +++ b/.classpath @@ -1,14 +1,14 @@ - - + + diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java index 725c8e7e..cc512bd8 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java @@ -210,7 +210,7 @@ public class SyntaxTreeGenerator{ if(ctx.superclass() != null){ superClass = convert(ctx.superclass()); }else{ - superClass = new ASTFactory(reg).createObjectClass().getType(); + superClass = new RefType(new JavaClassName("java.lang.Object"), new NullToken()); } Boolean isInterface = false; List implementedInterfaces = null; diff --git a/test/strucTypes/GeneralParserTest.java b/test/strucTypes/GeneralParserTest.java index b64291e0..63b1972a 100644 --- a/test/strucTypes/GeneralParserTest.java +++ b/test/strucTypes/GeneralParserTest.java @@ -5,7 +5,6 @@ import static org.junit.Assert.*; import java.io.File; import java.util.ArrayList; import java.util.List; - import de.dhbwstuttgart.parser.JavaTXParser; import de.dhbwstuttgart.strucTypes.AS_Abstract; import de.dhbwstuttgart.strucTypes.TC_Abstract; @@ -13,6 +12,7 @@ import de.dhbwstuttgart.strucTypes.Algo_Type; import de.dhbwstuttgart.strucTypes.Algo_TypeExpr; import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.statement.CastExpr; +import sun.reflect.generics.reflectiveObjects.NotImplementedException; import org.junit.Test; @@ -41,8 +41,8 @@ public class GeneralParserTest{ //filenames.add("GenericFieldVarTest.jav"); //filenames.add("FieldVarTest.jav"); - //filenames.add("StructuralTypesField.jav"); - filenames.add("StructuralTypesSimple3.jav"); + filenames.add("StructuralTypesField.jav"); + //filenames.add("Main.jav"); JavaTXParser parser = new JavaTXParser(); try{ @@ -60,15 +60,17 @@ public class GeneralParserTest{ // Print der Expression: - System.out.println(Algo_TypeExpr.expression2code(ass, sf.getClasses().get(0).getMethods().get(0).get_Block().statements)); - System.out.println(Algo_TypeExpr.expression2code(ass, sf.getClasses().get(0).getMethods().get(2).get_Block().statements)); + //System.out.println(Algo_TypeExpr.expression2code(ass, sf.getClasses().get(0).getMethods().get(0).get_Block().statements)); + //System.out.println(Algo_TypeExpr.expression2code(ass, sf.getClasses().get(0).getMethods().get(2).get_Block().statements)); // Erstellen der TypeExpression - - + // Wegen java Build path + if (false) { + throw new NotImplementedException(); + } } diff --git a/test/strucTypes/GeneralParserTest_Main.java b/test/strucTypes/GeneralParserTest_Main.java new file mode 100644 index 00000000..d2bb4572 --- /dev/null +++ b/test/strucTypes/GeneralParserTest_Main.java @@ -0,0 +1,70 @@ +package strucTypes; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import de.dhbwstuttgart.parser.JavaTXParser; +import de.dhbwstuttgart.strucTypes.AS_Abstract; +import de.dhbwstuttgart.strucTypes.TC_Abstract; +import de.dhbwstuttgart.strucTypes.Algo_Type; +import de.dhbwstuttgart.strucTypes.Algo_TypeExpr; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.statement.CastExpr; + +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_Main{ + private static final String rootDirectory = System.getProperty("user.dir")+"/test/strucTypes/"; + + @Test + public void run(){ + + /* + * Auflistung aller Files die getestet werden sollen + */ + List filenames = new ArrayList(); + //filenames.add("FieldInitializationTest.jav"); + //filenames.add("ImportTest.jav"); + //filenames.add("StatementsTest.jav"); + //filenames.add("ImportTestGeneric.jav"); + //filenames.add("BoundedParameter.jav"); + //filenames.add("GenericFieldVarTest.jav"); + //filenames.add("FieldVarTest.jav"); + + //filenames.add("StructuralTypesField.jav"); + filenames.add("Main.jav"); + + JavaTXParser parser = new JavaTXParser(); + try{ + for(String filename : filenames) { + + System.out.println("Teste: "+ filename); + + SourceFile sf = parser.parse(new File(rootDirectory + filename)); + + SourceFile sfdebug = sf; + + + + + + + } + }catch(Exception exc){ + exc.printStackTrace(); + fail(); + } + assertTrue("Tests durchlaufen",filenames.size()>0); + } + +} diff --git a/test/strucTypes/Main.jav b/test/strucTypes/Main.jav new file mode 100644 index 00000000..d1a00f52 --- /dev/null +++ b/test/strucTypes/Main.jav @@ -0,0 +1,6 @@ + +class Main { + +main() { return new A<>().mt(new myInteger(1)); } + +} \ No newline at end of file