forked from JavaTX/JavaCompilerCore
52 lines
1.6 KiB
Java
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);
|
|
}
|
|
|
|
}
|