From 6e03d2458236b8426d255b6cc58c5aa222b40441 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Tue, 19 Sep 2017 18:51:44 +0200 Subject: [PATCH] Tests auslagern --- .../core/CompilationEnvironment.java | 4 +++- test/javFiles/test.jav | 15 +++++++++++++++ test/typeinference/FacultyTest.java | 9 +++++++++ test/typeinference/GenericsTest.java | 9 +++++++++ test/typeinference/JavaTXCompilerTest.java | 17 ++++++++++++++--- test/typeinference/Lambda2Test.java | 9 +++++++++ test/typeinference/Lambda3Test.java | 9 +++++++++ test/typeinference/LambdaTest.java | 9 +++++++++ test/typeinference/VectorTest.java | 9 +++++++++ test/typeinference/mathStrucTest.java | 9 +++++++++ 10 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 test/javFiles/test.jav create mode 100644 test/typeinference/FacultyTest.java create mode 100644 test/typeinference/GenericsTest.java create mode 100644 test/typeinference/Lambda2Test.java create mode 100644 test/typeinference/Lambda3Test.java create mode 100644 test/typeinference/LambdaTest.java create mode 100644 test/typeinference/VectorTest.java create mode 100644 test/typeinference/mathStrucTest.java diff --git a/src/de/dhbwstuttgart/core/CompilationEnvironment.java b/src/de/dhbwstuttgart/core/CompilationEnvironment.java index 7cee44bc..99c7727a 100644 --- a/src/de/dhbwstuttgart/core/CompilationEnvironment.java +++ b/src/de/dhbwstuttgart/core/CompilationEnvironment.java @@ -3,7 +3,9 @@ package de.dhbwstuttgart.core; /** * Stellt die Java-Environment dar * Speichert alle Typen, Klassen aus den benutzen SourceFiles und Librarys + * + * Ersetzt die JavaClassNameRegistry */ public class CompilationEnvironment { - + // } diff --git a/test/javFiles/test.jav b/test/javFiles/test.jav new file mode 100644 index 00000000..b539c15d --- /dev/null +++ b/test/javFiles/test.jav @@ -0,0 +1,15 @@ +class Test{ + methode(param1, param2, param3) { + return param1.meth(param2.meth(param3)); + } +} + +interface Klasse1{ + Klasse1 meth(Klasse1 p); + Klasse1 meth(Klasse2 p); +} + +interface Klasse2{ + Klasse1 meth(Klasse1 p): + Klasse2 meth(Klasse2 p): +} \ No newline at end of file diff --git a/test/typeinference/FacultyTest.java b/test/typeinference/FacultyTest.java new file mode 100644 index 00000000..aadaf6e7 --- /dev/null +++ b/test/typeinference/FacultyTest.java @@ -0,0 +1,9 @@ +package typeinference; + +import java.io.File; + +public class FacultyTest extends JavaTXCompilerTest{ + public FacultyTest() { + this.fileToTest = new File(rootDirectory+"Faculty.jav"); + } +} \ No newline at end of file diff --git a/test/typeinference/GenericsTest.java b/test/typeinference/GenericsTest.java new file mode 100644 index 00000000..3811883d --- /dev/null +++ b/test/typeinference/GenericsTest.java @@ -0,0 +1,9 @@ +package typeinference; + +import java.io.File; + +public class GenericsTest extends JavaTXCompilerTest{ + public GenericsTest() { + this.fileToTest = new File(rootDirectory+"Generics.jav"); + } +} \ No newline at end of file diff --git a/test/typeinference/JavaTXCompilerTest.java b/test/typeinference/JavaTXCompilerTest.java index 495d087a..f4bbf723 100644 --- a/test/typeinference/JavaTXCompilerTest.java +++ b/test/typeinference/JavaTXCompilerTest.java @@ -10,6 +10,8 @@ import org.junit.Test; import java.io.File; import java.io.IOException; +import java.net.URL; +import java.net.URLClassLoader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -20,14 +22,22 @@ import java.util.Set; public class JavaTXCompilerTest extends JavaTXCompiler { - private static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/"; + public static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/"; private static final List filesToTest = new ArrayList<>(); + protected File fileToTest = null; + + public JavaTXCompilerTest(){ + } @Test public void test() throws IOException, java.lang.ClassNotFoundException { + for(URL url : ((URLClassLoader) (Thread.currentThread().getContextClassLoader())).getURLs()){ + System.out.println(url ); + } + if(fileToTest != null)filesToTest.add(fileToTest); //filesToTest.add(new File(rootDirectory+"Faculty.jav")); //filesToTest.add(new File(rootDirectory+"mathStruc.jav")); - filesToTest.add(new File(rootDirectory+"test.jav")); + //filesToTest.add(new File(rootDirectory+"test.jav")); //filesToTest.add(new File(rootDirectory+"Lambda.jav")); //filesToTest.add(new File(rootDirectory+"Lambda2.jav")); //filesToTest.add(new File(rootDirectory+"Lambda3.jav")); @@ -56,4 +66,5 @@ public class JavaTXCompilerTest extends JavaTXCompiler { return new String(encoded, encoding); } -} \ No newline at end of file +} + diff --git a/test/typeinference/Lambda2Test.java b/test/typeinference/Lambda2Test.java new file mode 100644 index 00000000..84867cd9 --- /dev/null +++ b/test/typeinference/Lambda2Test.java @@ -0,0 +1,9 @@ +package typeinference; + +import java.io.File; + +public class Lambda2Test extends JavaTXCompilerTest{ + public Lambda2Test() { + this.fileToTest = new File(rootDirectory+"Lambda2.jav"); + } +} \ No newline at end of file diff --git a/test/typeinference/Lambda3Test.java b/test/typeinference/Lambda3Test.java new file mode 100644 index 00000000..843eee10 --- /dev/null +++ b/test/typeinference/Lambda3Test.java @@ -0,0 +1,9 @@ +package typeinference; + +import java.io.File; + +public class Lambda3Test extends JavaTXCompilerTest{ + public Lambda3Test() { + this.fileToTest = new File(rootDirectory+"Lambda3.jav"); + } +} \ No newline at end of file diff --git a/test/typeinference/LambdaTest.java b/test/typeinference/LambdaTest.java new file mode 100644 index 00000000..abdaa140 --- /dev/null +++ b/test/typeinference/LambdaTest.java @@ -0,0 +1,9 @@ +package typeinference; + +import java.io.File; + +public class LambdaTest extends JavaTXCompilerTest{ + public LambdaTest() { + this.fileToTest = new File(rootDirectory+"Lambda.jav"); + } +} \ No newline at end of file diff --git a/test/typeinference/VectorTest.java b/test/typeinference/VectorTest.java new file mode 100644 index 00000000..864535b3 --- /dev/null +++ b/test/typeinference/VectorTest.java @@ -0,0 +1,9 @@ +package typeinference; + +import java.io.File; + +public class VectorTest extends JavaTXCompilerTest{ + public VectorTest() { + this.fileToTest = new File(rootDirectory+"Vector.jav"); + } +} \ No newline at end of file diff --git a/test/typeinference/mathStrucTest.java b/test/typeinference/mathStrucTest.java new file mode 100644 index 00000000..0181be72 --- /dev/null +++ b/test/typeinference/mathStrucTest.java @@ -0,0 +1,9 @@ +package typeinference; + +import java.io.File; + +public class mathStrucTest extends JavaTXCompilerTest{ + public mathStrucTest() { + this.fileToTest = new File(rootDirectory+"mathStruc.jav"); + } +} \ No newline at end of file