34 lines
1.1 KiB
Java
34 lines
1.1 KiB
Java
package astfactory;
|
|
|
|
//import javafx.collections.ObservableList;
|
|
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
|
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
|
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
|
import org.junit.Test;
|
|
|
|
import java.lang.reflect.ParameterizedType;
|
|
import java.lang.reflect.Type;
|
|
import java.lang.reflect.TypeVariable;
|
|
import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
public class ASTFactoryTest<A> extends HashMap<String, A>{
|
|
@Test
|
|
public void test(){
|
|
System.out.println((this.getClass().getGenericSuperclass()));
|
|
Type[] arguments = ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments();
|
|
System.out.println(Arrays.toString(arguments));
|
|
System.out.println(((TypeVariable)arguments[1]).getGenericDeclaration());
|
|
}
|
|
|
|
public static class GenericFieldTest<G>{
|
|
public G testField;
|
|
}
|
|
@Test
|
|
public void genericFieldTest(){
|
|
ClassOrInterface test = ASTFactory.createClass(GenericFieldTest.class);
|
|
assertTrue(test.getFieldDecl().get(0).getType() instanceof GenericRefType);
|
|
}
|
|
} |