forked from JavaTX/JavaCompilerCore
erzeugt Bytecode für relationale Operatoren. Getestet.
This commit is contained in:
parent
54cf24926e
commit
52a5fd7904
@ -14,6 +14,8 @@ import java.util.Iterator;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.*;
|
import de.dhbwstuttgart.syntaxtree.statement.*;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.statement.BinaryExpr.Operator;
|
||||||
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.Handle;
|
import org.objectweb.asm.Handle;
|
||||||
import org.objectweb.asm.Label;
|
import org.objectweb.asm.Label;
|
||||||
@ -178,91 +180,169 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
}
|
}
|
||||||
binary.lexpr.accept(this);
|
binary.lexpr.accept(this);
|
||||||
|
|
||||||
if(!getResolvedType(binary.lexpr.getType()).equals(typeOfBinary))
|
String lexpType = getResolvedType(binary.lexpr.getType());
|
||||||
doCast(getResolvedType(binary.lexpr.getType()), typeOfBinary);
|
String rexpType = getResolvedType(binary.rexpr.getType());
|
||||||
|
|
||||||
|
String largerType = getLargerType(lexpType,rexpType);
|
||||||
|
|
||||||
|
if(!lexpType.equals(rexpType) &&
|
||||||
|
!lexpType.equals(largerType))
|
||||||
|
doCast(lexpType, largerType);
|
||||||
|
|
||||||
binary.rexpr.accept(this);
|
binary.rexpr.accept(this);
|
||||||
|
|
||||||
if(!getResolvedType(binary.rexpr.getType()).equals(typeOfBinary))
|
if(!lexpType.equals(rexpType) &&
|
||||||
doCast(getResolvedType(binary.rexpr.getType()), typeOfBinary);
|
!rexpType.equals(largerType))
|
||||||
|
doCast(rexpType, largerType);
|
||||||
|
|
||||||
switch (binary.operation.toString()) {
|
Operator op = binary.operation;
|
||||||
case "ADD":
|
|
||||||
|
switch (op) {
|
||||||
|
case ADD:
|
||||||
doVisitAddOpInsn(typeOfBinary);
|
doVisitAddOpInsn(typeOfBinary);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "SUB":
|
case SUB:
|
||||||
doVisitSubOpInsn(typeOfBinary);
|
doVisitSubOpInsn(typeOfBinary);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "MUL":
|
case MUL:
|
||||||
doVisitMulOpInsn(typeOfBinary);
|
doVisitMulOpInsn(typeOfBinary);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "DIV":
|
case DIV:
|
||||||
doVisitDivOpInsn(typeOfBinary);
|
doVisitDivOpInsn(typeOfBinary);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "MOD":
|
case MOD:
|
||||||
doVisitModOpInsn(typeOfBinary);
|
doVisitModOpInsn(typeOfBinary);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "LESSTHAN":
|
case LESSTHAN:
|
||||||
doVisitLessOpInsn(typeOfBinary);
|
case LESSEQUAL:
|
||||||
|
case BIGGERTHAN:
|
||||||
|
case BIGGEREQUAL:
|
||||||
|
doVisitRelOpInsn(op,largerType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doCast(String typeOfExp, String typeOfBinary) {
|
private String getLargerType(String lexpType, String rexpType) {
|
||||||
switch (typeOfBinary) {
|
if(lexpType.equals(Type.getInternalName(Double.class)) ||
|
||||||
|
rexpType.equals(Type.getInternalName(Double.class))) {
|
||||||
|
return Type.getInternalName(Double.class);
|
||||||
|
} else if(lexpType.equals(Type.getInternalName(Float.class)) ||
|
||||||
|
rexpType.equals(Type.getInternalName(Float.class))) {
|
||||||
|
return Type.getInternalName(Float.class);
|
||||||
|
} else if(lexpType.equals(Type.getInternalName(Long.class)) ||
|
||||||
|
rexpType.equals(Type.getInternalName(Long.class))) {
|
||||||
|
return Type.getInternalName(Long.class);
|
||||||
|
} else {
|
||||||
|
return Type.getInternalName(Integer.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doCast(String sourceType, String dest) {
|
||||||
|
switch (dest) {
|
||||||
case "java/lang/Long":
|
case "java/lang/Long":
|
||||||
mv.visitInsn(Opcodes.I2L);
|
mv.visitInsn(Opcodes.I2L);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "java/lang/Double":
|
case "java/lang/Double":
|
||||||
if(typeOfExp.equals(Type.getInternalName(Long.class))) {
|
if(sourceType.equals(Type.getInternalName(Long.class))) {
|
||||||
mv.visitInsn(Opcodes.L2D);
|
mv.visitInsn(Opcodes.L2D);
|
||||||
} else if(typeOfExp.equals(Type.getInternalName(Float.class))) {
|
} else if(sourceType.equals(Type.getInternalName(Float.class))) {
|
||||||
mv.visitInsn(Opcodes.F2D);
|
mv.visitInsn(Opcodes.F2D);
|
||||||
} else {
|
} else {
|
||||||
mv.visitInsn(Opcodes.I2D);
|
mv.visitInsn(Opcodes.I2D);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "java/lang/Float":
|
||||||
|
if(sourceType.equals(Type.getInternalName(Long.class))) {
|
||||||
|
mv.visitInsn(Opcodes.L2F);
|
||||||
|
} else {
|
||||||
|
mv.visitInsn(Opcodes.I2F);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
private void doVisitRelOpInsn(Operator op, String typeOfBinary) {
|
||||||
private void doVisitLessOpInsn(String typeOfBinary) {
|
Label branchLabel = new Label();
|
||||||
|
Label endLabel = new Label();
|
||||||
|
|
||||||
switch (typeOfBinary) {
|
switch (typeOfBinary) {
|
||||||
case "java/lang/Long":
|
case "java/lang/Long":
|
||||||
mv.visitInsn(Opcodes.LCMP);
|
mv.visitInsn(Opcodes.LCMP);
|
||||||
|
doVisitIfInRelOp(op, branchLabel, endLabel);
|
||||||
break;
|
break;
|
||||||
case "java/lang/Double":
|
case "java/lang/Double":
|
||||||
mv.visitInsn(Opcodes.DCMPG);
|
mv.visitInsn(Opcodes.DCMPG);
|
||||||
|
doVisitIfInRelOp(op, branchLabel, endLabel);
|
||||||
break;
|
break;
|
||||||
case "java/lang/Float":
|
case "java/lang/Float":
|
||||||
mv.visitInsn(Opcodes.FCMPG);
|
mv.visitInsn(Opcodes.FCMPG);
|
||||||
|
doVisitIfInRelOp(op, branchLabel, endLabel);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Label greaterEq = new Label();
|
switch (op) {
|
||||||
mv.visitJumpInsn(Opcodes.IF_ICMPGE, greaterEq);
|
case LESSTHAN:
|
||||||
|
mv.visitJumpInsn(Opcodes.IF_ICMPGE, branchLabel);
|
||||||
|
break;
|
||||||
|
case LESSEQUAL:
|
||||||
|
mv.visitJumpInsn(Opcodes.IF_ICMPGT, branchLabel);
|
||||||
|
break;
|
||||||
|
case BIGGERTHAN:
|
||||||
|
mv.visitJumpInsn(Opcodes.IF_ICMPLE, branchLabel);
|
||||||
|
break;
|
||||||
|
case BIGGEREQUAL:
|
||||||
|
mv.visitJumpInsn(Opcodes.IF_ICMPLT, branchLabel);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
mv.visitInsn(Opcodes.ICONST_1);
|
mv.visitInsn(Opcodes.ICONST_1);
|
||||||
Label lessThan = new Label();
|
mv.visitJumpInsn(Opcodes.GOTO, endLabel);
|
||||||
mv.visitJumpInsn(Opcodes.GOTO, lessThan);
|
mv.visitLabel(branchLabel);
|
||||||
mv.visitLabel(greaterEq);
|
|
||||||
mv.visitInsn(Opcodes.ICONST_0);
|
mv.visitInsn(Opcodes.ICONST_0);
|
||||||
mv.visitLabel(lessThan);
|
mv.visitLabel(endLabel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doVisitIfInRelOp(Operator op, Label greaterEq, Label lessThan) {
|
||||||
|
switch (op) {
|
||||||
|
case LESSTHAN:
|
||||||
|
mv.visitJumpInsn(Opcodes.IFGE, greaterEq);
|
||||||
|
break;
|
||||||
|
case LESSEQUAL:
|
||||||
|
mv.visitJumpInsn(Opcodes.IFGT, greaterEq);
|
||||||
|
break;
|
||||||
|
case BIGGERTHAN:
|
||||||
|
mv.visitJumpInsn(Opcodes.IFLE, greaterEq);
|
||||||
|
break;
|
||||||
|
case BIGGEREQUAL:
|
||||||
|
mv.visitJumpInsn(Opcodes.IFLT, greaterEq);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mv.visitInsn(Opcodes.ICONST_1);
|
||||||
|
mv.visitJumpInsn(Opcodes.GOTO, lessThan);
|
||||||
|
mv.visitLabel(greaterEq);
|
||||||
|
mv.visitInsn(Opcodes.ICONST_0);
|
||||||
|
mv.visitLabel(lessThan);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void doVisitModOpInsn(String typeOfBinary) {
|
private void doVisitModOpInsn(String typeOfBinary) {
|
||||||
switch (typeOfBinary) {
|
switch (typeOfBinary) {
|
||||||
case "java/lang/Long":
|
case "java/lang/Long":
|
||||||
|
140
test/bytecode/GreaterEqualTest.java
Normal file
140
test/bytecode/GreaterEqualTest.java
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
public class GreaterEqualTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/GreaterEqual.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode();
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("File://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("GreaterEqual");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() {
|
||||||
|
assertEquals("GreaterEqual", classToTest.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 7, 5);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIntegers2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5, 7);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEqIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5, 5);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLongs() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Long.class, Long.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 10L,7L);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFloats() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Float.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5F,7F);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubles() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Double.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5.0,7.0);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Long.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 15L,7);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Float.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5F,7);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 25.0,17);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Float.class, Long.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 75F,70L);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Long.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5.0,7L);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEqDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 7.0,7F);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 15.0,7F);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleFloat3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 9.0,17F);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
139
test/bytecode/GreaterThanTest.java
Normal file
139
test/bytecode/GreaterThanTest.java
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
public class GreaterThanTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/GreaterThan.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode();
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("File://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("GreaterThan");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() {
|
||||||
|
assertEquals("GreaterThan", classToTest.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 7, 5);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIntegers2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5, 7);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEqIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5, 5);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLongs() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Long.class, Long.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 10L,7L);
|
||||||
|
assertTrue(result);
|
||||||
|
}@Test
|
||||||
|
|
||||||
|
public void testFloats() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5F,7F);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubles() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Double.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5.0,7.0);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Long.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 15L,7);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5F,7);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 25.0,17);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Long.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 75F,70L);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Long.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5.0,7L);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEqDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 7.0,7F);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 15.0,7F);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleFloat3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 9.0,17F);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
133
test/bytecode/LessEqualTest.java
Normal file
133
test/bytecode/LessEqualTest.java
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
public class LessEqualTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/LessEqual.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode();
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("LessEqual");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testName() {
|
||||||
|
assertEquals("LessEqual", classToTest.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5,7);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEqualIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5,5);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLongs() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Long.class, Long.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5L,7L);
|
||||||
|
assertTrue(result);
|
||||||
|
}@Test
|
||||||
|
|
||||||
|
public void testFloats() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Float.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5F,7F);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubles() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Double.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7.0);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Long.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5L,7);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5F,7);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Long.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5F,7L);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Long.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7L);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEqDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 7.0,7F);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7F);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDoubleFloat3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 9.0,7F);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
141
test/bytecode/LessThanTest.java
Normal file
141
test/bytecode/LessThanTest.java
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
public class LessThanTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/LessThan.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode();
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("LessThan");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClassName() {
|
||||||
|
assertEquals("LessThan", classToTest.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class,Integer.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5, 7);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanInt2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7, 5);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanInt3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5, 5);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class,Long.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5L, 7L);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanLong2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Long.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7L, 5L);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanLong3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Long.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5L, 5L);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Float.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7F, 5F);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanDouble() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Double.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5.0);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7L, 5);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7F, 5);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Long.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7F, 5L);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Long.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5L);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLessThanDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5F);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -148,14 +148,46 @@ public class OpTest {
|
|||||||
// Short s = 7;
|
// Short s = 7;
|
||||||
// Double result = (Double) add.invoke(instanceOfClass, s,3d);
|
// Double result = (Double) add.invoke(instanceOfClass, s,3d);
|
||||||
// assertEquals(10d, result);
|
// assertEquals(10d, result);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Test
|
||||||
|
// public void testAddByteD() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
||||||
|
// IllegalArgumentException, InvocationTargetException, InstantiationException {
|
||||||
|
// Method add = classToTest.getDeclaredMethod("add", Byte.class,Double.class);
|
||||||
|
// Byte b = 7;
|
||||||
|
// Double result = (Double) add.invoke(instanceOfClass, b,3d);
|
||||||
|
// assertEquals(10d, result);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddByteD() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
public void testMulInt() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
||||||
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
||||||
Method add = classToTest.getDeclaredMethod("add", Byte.class,Double.class);
|
Method mulInt = classToTest.getDeclaredMethod("mulInt", Integer.class,Integer.class);
|
||||||
Byte b = 7;
|
Integer result = (Integer) mulInt.invoke(instanceOfClass, 7,3);
|
||||||
Double result = (Double) add.invoke(instanceOfClass, b,3d);
|
assertEquals(21, result);
|
||||||
assertEquals(10d, result);
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMulLong() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
||||||
|
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
||||||
|
Method mulLong = classToTest.getDeclaredMethod("mulLong", Long.class,Long.class);
|
||||||
|
Long result = (Long) mulLong.invoke(instanceOfClass, 7L,3L);
|
||||||
|
assertEquals(21L, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMulFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
||||||
|
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
||||||
|
Method mulFloat = classToTest.getDeclaredMethod("mulFloat", Float.class,Float.class);
|
||||||
|
Float result = (Float) mulFloat.invoke(instanceOfClass, 7f,3f);
|
||||||
|
assertEquals(21f, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMulDouble() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
||||||
|
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
||||||
|
Method mulDouble = classToTest.getDeclaredMethod("mulDouble", Double.class,Double.class);
|
||||||
|
Double result = (Double) mulDouble.invoke(instanceOfClass, 7.0,3.0);
|
||||||
|
assertEquals(21.0, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
56
test/bytecode/javFiles/GreaterEqual.jav
Normal file
56
test/bytecode/javFiles/GreaterEqual.jav
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Long;
|
||||||
|
import java.lang.Float;
|
||||||
|
import java.lang.Double;
|
||||||
|
|
||||||
|
public class GreaterEqual {
|
||||||
|
gE(Integer a, Integer b){
|
||||||
|
var c = a>=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gE(Long a, Long b){
|
||||||
|
var c = a>=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gE(Float a, Float b){
|
||||||
|
var c = a>=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gE(Double a, Double b){
|
||||||
|
var c = a>=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gE(Long a, Integer b){
|
||||||
|
var c = a>=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gE(Float a, Integer b){
|
||||||
|
var c = a>=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gE(Double a, Integer b){
|
||||||
|
var c = a>=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gE(Float a, Long b){
|
||||||
|
var c = a>=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gE(Double a, Long b){
|
||||||
|
var c = a>=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gE(Double a, Float b){
|
||||||
|
var c = a>=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
56
test/bytecode/javFiles/GreaterThan.jav
Normal file
56
test/bytecode/javFiles/GreaterThan.jav
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Long;
|
||||||
|
import java.lang.Float;
|
||||||
|
import java.lang.Double;
|
||||||
|
|
||||||
|
public class GreaterThan {
|
||||||
|
gT(Integer a, Integer b){
|
||||||
|
var c = a>b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gT(Long a, Long b){
|
||||||
|
var c = a>b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gT(Float a, Float b){
|
||||||
|
var c = a>b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gT(Double a, Double b){
|
||||||
|
var c = a>b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gT(Long a, Integer b){
|
||||||
|
var c = a>b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gT(Float a, Integer b){
|
||||||
|
var c = a>b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gT(Double a, Integer b){
|
||||||
|
var c = a>b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gT(Float a, Long b){
|
||||||
|
var c = a>b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gT(Double a, Long b){
|
||||||
|
var c = a>b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
gT(Double a, Float b){
|
||||||
|
var c = a>b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
56
test/bytecode/javFiles/LessEqual.jav
Normal file
56
test/bytecode/javFiles/LessEqual.jav
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Long;
|
||||||
|
import java.lang.Float;
|
||||||
|
import java.lang.Double;
|
||||||
|
|
||||||
|
public class LessEqual {
|
||||||
|
lessEqual(Integer a, Integer b){
|
||||||
|
var c = a<=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessEqual(Long a, Long b){
|
||||||
|
var c = a<=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessEqual(Float a, Float b){
|
||||||
|
var c = a<=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessEqual(Double a, Double b){
|
||||||
|
var c = a<=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessEqual(Long a, Integer b){
|
||||||
|
var c = a<=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessEqual(Float a, Integer b){
|
||||||
|
var c = a<=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessEqual(Double a, Integer b){
|
||||||
|
var c = a<=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessEqual(Float a, Long b){
|
||||||
|
var c = a<=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessEqual(Double a, Long b){
|
||||||
|
var c = a<=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessEqual(Double a, Float b){
|
||||||
|
var c = a<=b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
57
test/bytecode/javFiles/LessThan.jav
Normal file
57
test/bytecode/javFiles/LessThan.jav
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Long;
|
||||||
|
import java.lang.Float;
|
||||||
|
import java.lang.Double;
|
||||||
|
|
||||||
|
public class LessThan {
|
||||||
|
|
||||||
|
lessThan(Integer a, Integer b){
|
||||||
|
var c = a<b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessThan(Long a, Long b){
|
||||||
|
var c = a<b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessThan(Float a, Float b){
|
||||||
|
var c = a<b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessThan(Double a, Double b){
|
||||||
|
var c = a<b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessThan(Long a, Integer b){
|
||||||
|
var c = a<b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessThan(Float a, Integer b){
|
||||||
|
var c = a<b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessThan(Double a, Integer b){
|
||||||
|
var c = a<b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessThan(Float a, Long b){
|
||||||
|
var c = a<b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessThan(Double a, Long b){
|
||||||
|
var c = a<b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
lessThan(Double a, Float b){
|
||||||
|
var c = a<b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
@ -51,6 +51,26 @@ public class Op {
|
|||||||
// return c;
|
// return c;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
mulInt(Integer a, Integer b) {
|
||||||
|
Integer c = a*b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
mulLong(Long a, Long b) {
|
||||||
|
Long c = a*b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
mulFloat(Float a, Float b) {
|
||||||
|
Float c = a*b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
mulDouble(Double a, Double b) {
|
||||||
|
Double c = a*b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
// add(Double a, Long b) {
|
// add(Double a, Long b) {
|
||||||
// Double c = a+b;
|
// Double c = a+b;
|
||||||
// return c;
|
// return c;
|
||||||
@ -81,8 +101,8 @@ public class Op {
|
|||||||
// return c;
|
// return c;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
add(Byte a, Double b) {
|
// add(Byte a, Double b) {
|
||||||
Double c = a+b;
|
// Double c = a+b;
|
||||||
return c;
|
// return c;
|
||||||
}
|
// }
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user