forked from JavaTX/JavaCompilerCore
-Test für Methodenaufrufe und Variablen erstellt
This commit is contained in:
parent
65a1038574
commit
5a7c2310a1
@ -56,10 +56,7 @@ public abstract class ASTBytecodeTest {
|
|||||||
|
|
||||||
String rootDirectory = getRootDirectory();
|
String rootDirectory = getRootDirectory();
|
||||||
|
|
||||||
System.out.println(rootDirectory);
|
|
||||||
|
|
||||||
JavaClass javaClass = result.getByteCode().getJavaClass();
|
JavaClass javaClass = result.getByteCode().getJavaClass();
|
||||||
System.out.println(javaClass.toString());
|
|
||||||
javaClass.dump(new File(rootDirectory+javaClass.getClassName()+".class"));
|
javaClass.dump(new File(rootDirectory+javaClass.getClassName()+".class"));
|
||||||
|
|
||||||
for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){
|
for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){
|
||||||
@ -68,7 +65,6 @@ public abstract class ASTBytecodeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
System.out.print(e.getMessage());
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,8 +87,4 @@ public abstract class ASTBytecodeTest {
|
|||||||
public String getTestName() {
|
public String getTestName() {
|
||||||
return "No Testname defined!";
|
return "No Testname defined!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
18
test/bytecode/MethodAndVariable.jav
Normal file
18
test/bytecode/MethodAndVariable.jav
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
26
test/bytecode/MethodsAndVariableTest.java
Normal file
26
test/bytecode/MethodsAndVariableTest.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user