Endabgabe #20
58
.lib/Kurzdokumentation.md
Normal file
58
.lib/Kurzdokumentation.md
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# Kurzdokumentation
|
||||||
|
|
||||||
|
## Aufgabenverteilung
|
||||||
|
|
||||||
|
### Maximilian Stahl und Jannik Rombach:
|
||||||
|
- **Scanner**
|
||||||
|
- **Parser**
|
||||||
|
- **AST**
|
||||||
|
- **AstBuilder**
|
||||||
|
- **Modul: ast**
|
||||||
|
- Alle
|
||||||
|
- **Modul: parser**
|
||||||
|
- Alle
|
||||||
|
- **Modul: visitor**
|
||||||
|
- Alle
|
||||||
|
- **Testmodul: parser**
|
||||||
|
- AstBuildertest.java
|
||||||
|
- Helper.java
|
||||||
|
- **Testfiles: singleFeatureTests**
|
||||||
|
- Alle
|
||||||
|
|
||||||
|
### Johannes Ehlert:
|
||||||
|
- **Semantische Analyse**
|
||||||
|
- **Modul: semantic**
|
||||||
|
- **Modul: typecheck**
|
||||||
|
- **Testmodul: parser**
|
||||||
|
- AstBuildertest.java
|
||||||
|
- **Testfiles: typedAstFeatureTests**
|
||||||
|
- Großteil
|
||||||
|
- **Testfiles: typedAstExceptionsTests**
|
||||||
|
- Großteil
|
||||||
|
|
||||||
|
### David Große:
|
||||||
|
- **Bytecodegenerator**
|
||||||
|
- **Modul: bytecode**
|
||||||
|
- Alle
|
||||||
|
|
||||||
|
### Lucas Janker:
|
||||||
|
- **Tests**
|
||||||
|
- **Modul: main**
|
||||||
|
- Alle
|
||||||
|
- **Testmodul: main**
|
||||||
|
- Alle
|
||||||
|
- **Testmodul: parser**
|
||||||
|
- ScannerTest.java
|
||||||
|
- ParserTest.java
|
||||||
|
- **Testmodul: semantic**
|
||||||
|
- **Testfiles: combinedFeatureTests**
|
||||||
|
- Alle
|
||||||
|
- **Testfiles: failureTests**
|
||||||
|
- Alle
|
||||||
|
- **Testfiles: Alle**
|
||||||
|
- Refactoring
|
||||||
|
- **Ordnerstrukturen**
|
||||||
|
- Großteil
|
||||||
|
- **Build**
|
||||||
|
- **Makefile**
|
||||||
|
- **Dokumentation**
|
@ -7,13 +7,25 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import javax.tools.JavaCompiler;
|
||||||
|
import javax.tools.ToolProvider;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class E2EReflectionsTest {
|
public class E2EReflectionsTest {
|
||||||
@Test
|
@Test
|
||||||
public void AllFeaturesClassExampleTest(){
|
public void AllFeaturesClassExampleTest(){
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Class.forName("resources.input.combinedFeatureTests.AllFeaturesClassExample");
|
Main.main(new String[]{"src/test/resources/input/combinedFeatureTests/AllFeaturesClassExample.java", "src/test/resources/output/raupenpiler"});
|
||||||
|
// Get the system Java compiler
|
||||||
|
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||||
|
// Assert that the compiler is available
|
||||||
|
assertNotNull(javac, "Java Compiler is not available");
|
||||||
|
javac.run(null, null, null, "src/test/resources/input/combinedFeatureTests/AllFeaturesClassExample.java");
|
||||||
|
|
||||||
|
Class<?> clazz = Class.forName("src.resources.input.combinedFeatureTests.AllFeaturesClassExample");
|
||||||
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
// Class<?> clazz = classLoader.loadClass("main.AllFeaturesClassExample");
|
||||||
|
|
||||||
// Class Name
|
// Class Name
|
||||||
assertEquals("main.AllFeaturesClassExample", clazz.getName());
|
assertEquals("main.AllFeaturesClassExample", clazz.getName());
|
||||||
@ -76,6 +88,8 @@ public class E2EReflectionsTest {
|
|||||||
|
|
||||||
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,33 +54,33 @@ public class InputFilesTest {
|
|||||||
* The test passes if all the files fail to compile.
|
* The test passes if all the files fail to compile.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void areTestFilesActuallyFails() {
|
public void areTestFilesActuallyFails() throws IOException {
|
||||||
// Get the system Java compiler
|
// Get the system Java compiler
|
||||||
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||||
// Assert that the compiler is available
|
// Assert that the compiler is available
|
||||||
assertNotNull(javac, "Java Compiler is not available");
|
assertNotNull(javac, "Java Compiler is not available");
|
||||||
|
|
||||||
String directoryPath = "src/test/resources/input/failureTests";
|
|
||||||
File folder = new File(directoryPath);
|
|
||||||
|
|
||||||
if (folder.isDirectory()) {
|
File folder1 = new File("src/test/resources/input/failureTests");
|
||||||
File[] files = folder.listFiles((dir, name) -> name.endsWith(".java"));
|
File folder2 = new File("src/test/resources/input/typedAstExceptionsTest");
|
||||||
|
|
||||||
if (files != null) {
|
List<File> files = getJavaFilesFromDirectory(folder1);
|
||||||
for (File file : files) {
|
files.addAll(getJavaFilesFromDirectory(folder2));
|
||||||
// Try to compile the file and get the result
|
|
||||||
// The run method returns 0 if the compilation was successful, and non-zero otherwise
|
|
||||||
int result = javac.run(null, null, null, file.getPath());
|
|
||||||
|
|
||||||
// Assert that the compilation failed (i.e., the result is non-zero)
|
|
||||||
assertTrue(result != 0, "Expected compilation failure for " + file.getName());
|
if (!files.isEmpty()) {
|
||||||
}
|
for (File file : files) {
|
||||||
} else {
|
// Try to compile the file and get the result
|
||||||
System.out.println("No files found in the directory.");
|
// The run method returns 0 if the compilation was successful, and non-zero otherwise
|
||||||
|
int result = javac.run(null, null, null, file.getPath());
|
||||||
|
|
||||||
|
// Assert that the compilation failed (i.e., the result is non-zero)
|
||||||
|
assertTrue(result != 0, "Expected compilation failure for " + file.getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("The provided path is not a directory.");
|
System.out.println("No files found in the directory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@ public class AllFeaturesClassExample {
|
|||||||
char c;
|
char c;
|
||||||
|
|
||||||
// Konstruktor
|
// Konstruktor
|
||||||
AllFeaturesClassExample(int a, boolean b, char c) {
|
public AllFeaturesClassExample(int a, boolean b, char c) {
|
||||||
this.a = a;
|
this.a = a;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
this.c = c;
|
this.c = c;
|
||||||
@ -19,12 +19,12 @@ public class AllFeaturesClassExample {
|
|||||||
|
|
||||||
// while Schleife
|
// while Schleife
|
||||||
while (a > 0) {
|
while (a > 0) {
|
||||||
System.out.println("a ist " + a);
|
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
|
int c = 0;
|
||||||
// for Schleife
|
// for Schleife
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
|
c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -60,6 +60,10 @@ public class AllFeaturesClassExample {
|
|||||||
return a % b;
|
return a % b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean greaterThan(int a, int b) {
|
||||||
|
return a > b;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
|
AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
|
||||||
obj.controlStructures();
|
obj.controlStructures();
|
||||||
|
Loading…
Reference in New Issue
Block a user