forked from JavaTX/JavaCompilerCore
Test, bei dem Bug 72 auftritt
This commit is contained in:
parent
8870bc326c
commit
a0de7a4467
@ -288,7 +288,18 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
mv.visitInsn(Opcodes.I2F);
|
||||
}
|
||||
break;
|
||||
|
||||
// braucht man eigentlic nicht, muss getestet werden
|
||||
case "java/lang/String":
|
||||
if(sourceType.equals(Type.getInternalName(Double.class))) {
|
||||
mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(String.class), "valueOf", "(D)Ljava/lang/String;", false);
|
||||
} else if(sourceType.equals(Type.getInternalName(Long.class))) {
|
||||
mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(String.class), "valueOf", "(J)Ljava/lang/String;", false);
|
||||
} else if(sourceType.equals(Type.getInternalName(Float.class))) {
|
||||
mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(String.class), "valueOf", "(F)Ljava/lang/String;", false);
|
||||
} else {
|
||||
mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(String.class), "valueOf", "(I)Ljava/lang/String;", false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -808,7 +819,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
@Override
|
||||
public void visit(Literal literal) {
|
||||
Object value = literal.value;
|
||||
String typeOfLiteral = resultSet.resolveType(literal.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
String typeOfLiteral = getResolvedType(literal.getType());
|
||||
// Name der Methode muss geändert werden
|
||||
doAssign(typeOfLiteral, value, false);
|
||||
|
||||
|
39
test/bytecode/Op2Test.java
Normal file
39
test/bytecode/Op2Test.java
Normal file
@ -0,0 +1,39 @@
|
||||
package bytecode;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
|
||||
public class Op2Test {
|
||||
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/Op2.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("Op2");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
@Test
|
||||
public void test() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
}
|
11
test/bytecode/javFiles/Op2.jav
Normal file
11
test/bytecode/javFiles/Op2.jav
Normal file
@ -0,0 +1,11 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
|
||||
public class Op2 {
|
||||
m(){
|
||||
var x = "";
|
||||
var a = 5+x;
|
||||
|
||||
return a;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user