JavaTXCompilerInJavaTX/test/unify/GenerateFiniteClosure.java
JanUlrich 7b9a00a7e6 Revert "Syntaxbaum bereinigen. Allen Code löschen. Nur Struktur bleibt erhalten"
This reverts commit 3ab96a3ed74f41435b6b41502377f5a0084e6d75.
2016-12-16 01:05:54 +01:00

52 lines
1.6 KiB
Java

package unify;
import static org.junit.Assert.*;
import java.util.Set;
import org.junit.Test;
import de.dhbwstuttgart.syntaxtree.ImportDeclarations;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
import de.dhbwstuttgart.syntaxtree.misc.UsedId;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
public class GenerateFiniteClosure{
private TypeAssumptions generateAssumptionsFromImport(String importClass){
SourceFile sf = new SourceFile();
ImportDeclarations imports = new ImportDeclarations();
imports.add(new UsedId(importClass,0));
TypeAssumptions ass = sf.makeBasicAssumptionsFromJRE(imports, true);
return ass;
}
@Test
public void generateTypeAssumptions(){
Menge<String> imports = new Menge<>();
imports.add("java.util.Vector");
imports.add("java.lang.Boolean");
imports.add("java.util.ArrayList");
for(String importClass : imports){
TypeAssumptions ass = generateAssumptionsFromImport(importClass);
assertTrue(ass.getClassAssumptionFor(new RefType(importClass,null,0))!=null);
}
}
@Test
public void test() {
String importClass = "java.util.Vector";
TypeAssumptions ass = generateAssumptionsFromImport(importClass);
FiniteClosure fc = UnifyTypeFactory.generateFC(ass);
Set<UnifyType> test = fc.getAllTypesByName(importClass);
assertTrue(test.size()>0);
}
}