cleaning up

This commit is contained in:
JonathanFleischmann 2024-07-04 21:52:34 +02:00
parent 64721f2ab0
commit 13548771ca
30 changed files with 77 additions and 168 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@ target/
!.mvn/wrapper/maven-wrapper.jar !.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/ !**/src/main/**/target/
!**/src/test/**/target/ !**/src/test/**/target/
/personalNotes/
### IntelliJ IDEA ### ### IntelliJ IDEA ###
.idea .idea

View File

@ -8,23 +8,6 @@ import static HelpClasses.TestFileTester.run;
*/ */
class AllE2ETests { class AllE2ETests {
// @Test
// void testPublicClass() {
// byte[] resultE2E = Compiler.generateE2EArrayFromTypedAst();
// assertEquals(AbstractSyntax_PublicClass.get(), resultE2E);
// }
// @Test
// void testMethodCall() {
// assertDoesNotThrow(() -> {
// E2ETestUtil testUtility = new E2ETestUtil("src/test/testFiles/ASTandTypedASTFeatures/MethodCall.java", "MethodCall");
//
// assertEquals(0, testUtility.invokeMethod("method", null));
// assertEquals(1, testUtility.invokeMethod("method1", new Class<?>[]{int.class}, 1));
// assertEquals(3, testUtility.invokeMethod("method2", new Class<?>[]{int.class, int.class}, 1, 2));
// });
// } TODO: Fix this test or remove it
@Test @Test
void runE2EBreakTests() { void runE2EBreakTests() {
run(E2E_Break.class); run(E2E_Break.class);
@ -105,11 +88,6 @@ class AllE2ETests {
run(E2E_MethodCall.class); run(E2E_MethodCall.class);
} }
// @Test
// void runE2EMultipleClassesTests() {
// run(E2E_MultipleClasses.class);
// } TODO: Fix this test or remove it
@Test @Test
void runE2EOperatorsTests() { void runE2EOperatorsTests() {
run(E2E_Operators.class); run(E2E_Operators.class);

View File

@ -1,29 +0,0 @@
package E2ETests;
import java.util.HashMap;
import java.util.Map;
public class ByteClassLoader extends ClassLoader {
// TODO: Use or remove this class
// Map to store the class name and its corresponding byte array
private final Map<String, byte[]> classesBytes = new HashMap<>();
public ByteClassLoader() {
super(ClassLoader.getSystemClassLoader());
}
// Method to add a class byte array to the loader
public void addClass(String name, byte[] classData) {
classesBytes.put(name, classData);
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte[] classData = classesBytes.get(name);
if (classData == null) {
return super.findClass(name);
}
return defineClass(name, classData, 0, classData.length);
}
}

View File

@ -1,33 +0,0 @@
package E2ETests;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;
public class ClassNameExtractor {
// TODO: Use or remove this class
public static String getClassName(byte[] classBytes) {
ClassReader classReader = new ClassReader(classBytes);
ClassNameVisitor classNameVisitor = new ClassNameVisitor();
classReader.accept(classNameVisitor, 0);
return classNameVisitor.getClassName();
}
private static class ClassNameVisitor extends ClassVisitor {
private String className;
public ClassNameVisitor() {
super(Opcodes.ASM9);
}
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
this.className = name.replace('/', '.');
}
public String getClassName() {
return className;
}
}
}

View File

@ -3,7 +3,7 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
/** /**
* Test class for testing if the compilation of the class 'Break' at src/test/testFiles/E2EFeatures/Break.java was successful, * Test class for testing if the compilation of the class 'Break' at src/test/testFiles/E2EFeatures/Break.java was successful,
@ -14,7 +14,7 @@ public class E2E_Break {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Break {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Break.java", "Break"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Break.java", "Break");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -3,7 +3,7 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
/** /**
* Test class for testing if the compilation of the class 'Class' at src/test/testFiles/E2EFeatures/Class.java was successful, * Test class for testing if the compilation of the class 'Class' at src/test/testFiles/E2EFeatures/Class.java was successful,
@ -14,7 +14,7 @@ public class E2E_Class {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Class {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Class.java", "Class"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Class.java", "Class");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_ClassObjects {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_ClassObjects {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/ClassObjects.java", "ClassObjects"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/ClassObjects.java", "ClassObjects");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -3,7 +3,7 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
/** /**
* Test class for testing if the compilation of the class 'Comment' at src/test/testFiles/E2EFeatures/Comment.java was successful, * Test class for testing if the compilation of the class 'Comment' at src/test/testFiles/E2EFeatures/Comment.java was successful,
@ -14,7 +14,7 @@ public class E2E_Comment {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Comment {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Comment.java", "Comment"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Comment.java", "Comment");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_CompAssign {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_CompAssign {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/CompAssign.java", "CompAssign"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/CompAssign.java", "CompAssign");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_ComplexCalls {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_ComplexCalls {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/ComplexCalls.java", "ComplexCalls"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/ComplexCalls.java", "ComplexCalls");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_Constructor {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Constructor {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Constructor.java", "Constructor"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Constructor.java", "Constructor");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_Continue {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Continue {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Continue.java", "Continue"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Continue.java", "Continue");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -3,16 +3,14 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import java.util.List;
public class E2E_DataTypes { public class E2E_DataTypes {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -20,7 +18,7 @@ public class E2E_DataTypes {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/DataTypes.java", "DataTypes"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/DataTypes.java", "DataTypes");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -3,7 +3,7 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
/** /**
* Test class for testing if the compilation of the class 'Field' at src/test/testFiles/E2EFeatures/Field.java was successful, * Test class for testing if the compilation of the class 'Field' at src/test/testFiles/E2EFeatures/Field.java was successful,
@ -14,7 +14,7 @@ public class E2E_Field {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Field {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Field.java", "Field"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Field.java", "Field");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -3,7 +3,7 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
/** /**
* Test class for testing if the compilation of the class 'For' at src/test/testFiles/E2EFeatures/For.java was successful, * Test class for testing if the compilation of the class 'For' at src/test/testFiles/E2EFeatures/For.java was successful,
@ -14,7 +14,7 @@ public class E2E_For {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_For {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/For.java", "For"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/For.java", "For");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -3,7 +3,7 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
/** /**
* Test class for testing if the compilation of the class 'If' at src/test/testFiles/E2EFeatures/If.java was successful, * Test class for testing if the compilation of the class 'If' at src/test/testFiles/E2EFeatures/If.java was successful,
@ -14,7 +14,7 @@ public class E2E_If {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_If {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/If.java", "If"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/If.java", "If");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_InDeCrement {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_InDeCrement {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/InDeCrement.java", "InDeCrement"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/InDeCrement.java", "InDeCrement");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_LogicExpr {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_LogicExpr {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/LogicExpr.java", "LogicExpr"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/LogicExpr.java", "LogicExpr");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -17,7 +17,7 @@ public class E2E_Main {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -25,7 +25,7 @@ public class E2E_Main {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Main.java", "Main"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Main.java", "Main");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -171,6 +171,4 @@ public class E2E_Main {
Assertions.fail(); Assertions.fail();
} }
} }
//TODO: Add test for invoking main method by starting the compiled class file?
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_Method {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Method {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Method.java", "Method"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Method.java", "Method");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_MethodCall {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_MethodCall {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/MethodCall.java", "MethodCall"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/MethodCall.java", "MethodCall");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,10 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil;
import de.maishai.Compiler; import de.maishai.Compiler;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.List; import java.util.List;

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_Operators {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Operators {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Operators.java", "Operators"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Operators.java", "Operators");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_Overloaded {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Overloaded {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Overloaded.java", "Overloaded"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Overloaded.java", "Overloaded");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -3,7 +3,7 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.PrintStream; import java.io.PrintStream;
@ -17,7 +17,7 @@ public class E2E_Print {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -25,7 +25,7 @@ public class E2E_Print {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Print.java", "Print"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Print.java", "Print");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -3,7 +3,7 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
/** /**
* Test class for testing if the compilation of the class 'Return' at src/test/testFiles/E2EFeatures/Return.java was successful, * Test class for testing if the compilation of the class 'Return' at src/test/testFiles/E2EFeatures/Return.java was successful,
@ -14,7 +14,7 @@ public class E2E_Return {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Return {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Return.java", "Return"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Return.java", "Return");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,6 +1,6 @@
package E2ETests.Features; package E2ETests.Features;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -14,7 +14,7 @@ public class E2E_Unary {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_Unary {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/Unary.java", "Unary"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/Unary.java", "Unary");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -3,7 +3,7 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
/** /**
* Test class for testing if the compilation of the class 'VariableDefWithDecl' at src/test/testFiles/E2EFeatures/VariableDefWithDecl.java was successful, * Test class for testing if the compilation of the class 'VariableDefWithDecl' at src/test/testFiles/E2EFeatures/VariableDefWithDecl.java was successful,
@ -14,7 +14,7 @@ public class E2E_VariableDefWithDecl {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_VariableDefWithDecl {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/VariableDefWithDecl.java", util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/VariableDefWithDecl.java",
"VariableDefWithDecl"); "VariableDefWithDecl");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);

View File

@ -3,7 +3,7 @@ package E2ETests.Features;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import E2ETests.BytecodeTestUtil; import E2ETests.ReflectionsTestUtil;
/** /**
* Test class for testing if the compilation of the class 'While' at src/test/testFiles/E2EFeatures/While.java was successful, * Test class for testing if the compilation of the class 'While' at src/test/testFiles/E2EFeatures/While.java was successful,
@ -14,7 +14,7 @@ public class E2E_While {
/** /**
* The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class * The BytecodeTestUtil instance for the test class, which provides methods for testing the compiled class
*/ */
private BytecodeTestUtil util; private ReflectionsTestUtil util;
/** /**
* Initializes the BytecodeTestUtil instance for the test class * Initializes the BytecodeTestUtil instance for the test class
@ -22,7 +22,7 @@ public class E2E_While {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
try { try {
util = new BytecodeTestUtil("src/test/testFiles/E2EFeatures/While.java", "While"); util = new ReflectionsTestUtil("src/test/testFiles/E2EFeatures/While.java", "While");
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -11,7 +11,7 @@ import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
public class BytecodeTestUtil { public class ReflectionsTestUtil {
/** /**
* Class object representing the class that was compiled and can be analysed using reflection * Class object representing the class that was compiled and can be analysed using reflection
@ -24,7 +24,7 @@ public class BytecodeTestUtil {
/** /**
* Logger to log exceptions * Logger to log exceptions
*/ */
private static final Logger LOGGER = Logger.getLogger(BytecodeTestUtil.class.getName()); private static final Logger LOGGER = Logger.getLogger(ReflectionsTestUtil.class.getName());
/** /**
* Constructor to compile the source files, load the Class<?>-Object and create an instance of the class * Constructor to compile the source files, load the Class<?>-Object and create an instance of the class
@ -32,7 +32,7 @@ public class BytecodeTestUtil {
* @param className Name of the class to be loaded into the Class<?>-Object and create an instance of * @param className Name of the class to be loaded into the Class<?>-Object and create an instance of
* @throws Exception If any exception occurs * @throws Exception If any exception occurs
*/ */
public BytecodeTestUtil(String sourceFilePath, String className) throws Exception { public ReflectionsTestUtil(String sourceFilePath, String className) throws Exception {
// Generate bytecode from source file // Generate bytecode from source file
byte[] resultBytecode = Compiler.generateByteCodeArrayFromFiles(List.of(sourceFilePath)).get(0); byte[] resultBytecode = Compiler.generateByteCodeArrayFromFiles(List.of(sourceFilePath)).get(0);