From 5a7c2310a1a6c9e1438f41130b1aa0f1c73f733a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Schr=C3=B6dter?= Date: Tue, 19 Apr 2016 14:40:29 +0200 Subject: [PATCH] =?UTF-8?q?-Test=20f=C3=BCr=20Methodenaufrufe=20und=20Vari?= =?UTF-8?q?ablen=20erstellt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/bytecode/ASTBytecodeTest.java | 8 ------- test/bytecode/MethodAndVariable.jav | 18 ++++++++++++++++ test/bytecode/MethodsAndVariableTest.java | 26 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 test/bytecode/MethodAndVariable.jav create mode 100644 test/bytecode/MethodsAndVariableTest.java diff --git a/test/bytecode/ASTBytecodeTest.java b/test/bytecode/ASTBytecodeTest.java index 32fd8088..d2b4af70 100644 --- a/test/bytecode/ASTBytecodeTest.java +++ b/test/bytecode/ASTBytecodeTest.java @@ -56,10 +56,7 @@ public abstract class ASTBytecodeTest { String rootDirectory = getRootDirectory(); - System.out.println(rootDirectory); - JavaClass javaClass = result.getByteCode().getJavaClass(); - System.out.println(javaClass.toString()); javaClass.dump(new File(rootDirectory+javaClass.getClassName()+".class")); for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){ @@ -68,7 +65,6 @@ public abstract class ASTBytecodeTest { } }catch(Exception e){ - System.out.print(e.getMessage()); throw new RuntimeException(e); } } @@ -91,8 +87,4 @@ public abstract class ASTBytecodeTest { public String getTestName() { return "No Testname defined!"; } - - - - } diff --git a/test/bytecode/MethodAndVariable.jav b/test/bytecode/MethodAndVariable.jav new file mode 100644 index 00000000..2ae7002e --- /dev/null +++ b/test/bytecode/MethodAndVariable.jav @@ -0,0 +1,18 @@ +class MethodAndVariable{ + public Integer method(Integer parameter){ + Integer lokaleVariable; + lokaleVariable = 2; + + Integer lokaleVariable2; + lokaleVariable2 = method2(lokaleVariable); + + return parameter+lokaleVariable2; + } + + public Integer method2(Integer parameter){ + Integer lokaleVariable; + lokaleVariable = 2; + + return parameter+lokaleVariable; + } +} \ No newline at end of file diff --git a/test/bytecode/MethodsAndVariableTest.java b/test/bytecode/MethodsAndVariableTest.java new file mode 100644 index 00000000..8e0fd808 --- /dev/null +++ b/test/bytecode/MethodsAndVariableTest.java @@ -0,0 +1,26 @@ +package bytecode; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import bytecode.SourceFileBytecodeTest; + + +public class MethodsAndVariableTest extends SourceFileBytecodeTest{ + @Override + protected void init() { + testName = "MethodAndVariable"; + rootDirectory = System.getProperty("user.dir")+"/test/bytecode/"; + } + + @Test + public void testConstruct() throws Exception{ + ClassLoader classLoader = getClassLoader(); + + Class cls = classLoader.loadClass(testName); + + Object obj = cls.newInstance(); + assertTrue(true); + } +}