From ee2553b0899e1d37364c10e13cee4694e9b30b64 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 25 Jun 2024 17:26:31 +0200 Subject: [PATCH] add some e2e tests and make BytecodeTestUtil usable with different constructors --- .../de/maishai/typedast/MethodContext.java | 10 ++++- .../typedast/typedclass/TypedConstructor.java | 2 +- src/test/java/CodegeneratorTests.java | 3 +- src/test/java/{ => e2e}/BytecodeTestUtil.java | 27 +++++++++---- src/test/java/e2e/TestConstructor.java | 34 +++++++++++++++++ src/test/java/e2e/TestForLoop.java | 33 ++++++++++++++++ src/test/java/e2e/TestIf.java | 33 ++++++++++++++++ src/test/java/e2e/TestNewClass.java | 17 +++++++++ src/test/java/e2e/TestWhileLoop.java | 32 ++++++++++++++++ src/test/testFiles/e2e/Constructor.java | 18 +++++++++ src/test/testFiles/e2e/ForLoop.java | 31 +++++++++++++++ src/test/testFiles/e2e/If.java | 22 +++++++++++ src/test/testFiles/e2e/NewClass.java | 13 +++++++ src/test/testFiles/e2e/WhileLoop.java | 38 +++++++++++++++++++ 14 files changed, 301 insertions(+), 12 deletions(-) rename src/test/java/{ => e2e}/BytecodeTestUtil.java (57%) create mode 100644 src/test/java/e2e/TestConstructor.java create mode 100644 src/test/java/e2e/TestForLoop.java create mode 100644 src/test/java/e2e/TestIf.java create mode 100644 src/test/java/e2e/TestNewClass.java create mode 100644 src/test/java/e2e/TestWhileLoop.java create mode 100644 src/test/testFiles/e2e/Constructor.java create mode 100644 src/test/testFiles/e2e/ForLoop.java create mode 100644 src/test/testFiles/e2e/If.java create mode 100644 src/test/testFiles/e2e/NewClass.java create mode 100644 src/test/testFiles/e2e/WhileLoop.java diff --git a/src/main/java/de/maishai/typedast/MethodContext.java b/src/main/java/de/maishai/typedast/MethodContext.java index adb54d2..17b234e 100644 --- a/src/main/java/de/maishai/typedast/MethodContext.java +++ b/src/main/java/de/maishai/typedast/MethodContext.java @@ -1,6 +1,6 @@ package de.maishai.typedast; -import lombok.*; +import lombok.Getter; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; @@ -16,6 +16,7 @@ public class MethodContext { } private MethodVisitor mv; + private Type returnType; private final ClassContext classContext; private int localVarIndex = 0; private final Map variableIndex = new HashMap<>(); @@ -26,9 +27,10 @@ public class MethodContext { //used to jump to the start of the loop with continue private final Stack