Doku, AllFeaturesClassExample not running!!!
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
Lucas 2024-07-03 14:08:27 +02:00
parent 2bf73385af
commit 1cf1aaf837
4 changed files with 96 additions and 20 deletions

58
.lib/Kurzdokumentation.md Normal file
View 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**

View File

@ -7,13 +7,25 @@ import java.util.Arrays;
import org.junit.jupiter.api.Test;
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
import static org.junit.jupiter.api.Assertions.*;
public class E2EReflectionsTest {
@Test
public void AllFeaturesClassExampleTest(){
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
assertEquals("main.AllFeaturesClassExample", clazz.getName());
@ -76,6 +88,8 @@ public class E2EReflectionsTest {
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
e.printStackTrace();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -54,33 +54,33 @@ public class InputFilesTest {
* The test passes if all the files fail to compile.
*/
@Test
public void areTestFilesActuallyFails() {
public void areTestFilesActuallyFails() throws IOException {
// Get the system Java compiler
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
// Assert that the compiler is available
assertNotNull(javac, "Java Compiler is not available");
String directoryPath = "src/test/resources/input/failureTests";
File folder = new File(directoryPath);
if (folder.isDirectory()) {
File[] files = folder.listFiles((dir, name) -> name.endsWith(".java"));
File folder1 = new File("src/test/resources/input/failureTests");
File folder2 = new File("src/test/resources/input/typedAstExceptionsTest");
if (files != null) {
for (File file : files) {
// 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());
List<File> files = getJavaFilesFromDirectory(folder1);
files.addAll(getJavaFilesFromDirectory(folder2));
// Assert that the compilation failed (i.e., the result is non-zero)
assertTrue(result != 0, "Expected compilation failure for " + file.getName());
}
} else {
System.out.println("No files found in the directory.");
if (!files.isEmpty()) {
for (File file : files) {
// 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());
}
} else {
System.out.println("The provided path is not a directory.");
System.out.println("No files found in the directory.");
}
}
/**

View File

@ -4,7 +4,7 @@ public class AllFeaturesClassExample {
char c;
// Konstruktor
AllFeaturesClassExample(int a, boolean b, char c) {
public AllFeaturesClassExample(int a, boolean b, char c) {
this.a = a;
this.b = b;
this.c = c;
@ -19,12 +19,12 @@ public class AllFeaturesClassExample {
// while Schleife
while (a > 0) {
System.out.println("a ist " + a);
a--;
}
int c = 0;
// for Schleife
for (int i = 0; i < 5; i++) {
c++;
}
}
@ -60,6 +60,10 @@ public class AllFeaturesClassExample {
return a % b;
}
boolean greaterThan(int a, int b) {
return a > b;
}
public static void main(String[] args) {
AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
obj.controlStructures();