ExtendsVecorStringTest teilweise in ASTBytecodeTest überführt

This commit is contained in:
Enrico Schrödter 2015-11-10 19:28:47 +01:00
parent ecad9e138c
commit f18fcd2b12
3 changed files with 42 additions and 37 deletions

View File

@ -1,5 +0,0 @@
import java.util.Vector;
class ExtendsVectorString extends Vector<String>{
}

View File

@ -2,46 +2,56 @@ package bytecode.types;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Vector;
import junit.framework.TestCase;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import bytecode.SourceFileBytecodeTest; import bytecode.ASTBytecodeTest;
import plugindevelopment.TypeInsertTester; import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.core.MyCompilerAPI; import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.logger.LoggerConfiguration;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.parser.JavaParser.yyException;
import de.dhbwstuttgart.typeinference.ByteCodeResult;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
public class ExtendsVectorStringTest extends SourceFileBytecodeTest{
@Override public class ExtendsVectorStringTest extends ASTBytecodeTest{
protected void init() { public static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
testName = "ExtendsVectorString";
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/"; protected static String testName = "ExtendsVectorString";
@BeforeClass
public static void init(){
/*
import java.util.Vector;
class ExtendsVector extends Vector<String>{
}
*/
Menge<Type> parameter = new Menge<>();
parameter.add(new RefType("java.lang.String", sourceFile, 0));
de.dhbwstuttgart.syntaxtree.Class classToTest = ASTFactory.createClass(testName, new RefType("java.util.Vector", parameter, sourceFile, 0), null, null, sourceFile);
sourceFile.addElement(classToTest);
} }
@Test @Test
public void testConstruct() throws Exception{ public void testSupertype(){
ClassLoader classLoader = getClassLoader(); try{
ClassLoader classLoader = getClassLoader();
Class cls = classLoader.loadClass(testName); Class cls = classLoader.loadClass(testName);
Object obj = cls.newInstance(); assertEquals("java.util.Vector", cls.getSuperclass().getName());
}catch(Exception e){
Constructor method = cls.getConstructor(new Class[]{}); e.printStackTrace();
method.newInstance(); fail();
assertTrue(true); }
}
@Test
public void testParameter(){
throw new RuntimeException("Not implemented yet!");
} }
} }

View File

@ -13,9 +13,9 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
public class ExtendsVectorTest extends ASTBytecodeTest{ public class ExtendsVectorTest extends ASTBytecodeTest{
public static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/"; public static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
protected static String testName = "ExtendsVectorTest2"; protected static String testName = "ExtendsVectorTest";
@BeforeClass @BeforeClass
public static void init(){ public static void init(){