-Test für Methodenaufrufe und Variablen erstellt

This commit is contained in:
Enrico Schrödter 2016-04-19 14:40:29 +02:00
parent 65a1038574
commit 5a7c2310a1
3 changed files with 44 additions and 8 deletions

View File

@ -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!";
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}