diff options
author | sefftinge | 2008-03-13 11:37:21 +0000 |
---|---|---|
committer | sefftinge | 2008-03-13 11:37:21 +0000 |
commit | 232e41d1138346e0b17d900c4865d46d894e2add (patch) | |
tree | 424913705ab3616ed4ca2d5276d6bb0cad54d904 | |
parent | 799a7cd3858de67575e72f6c58a4d67ed601a5d7 (diff) | |
download | org.eclipse.xpand-232e41d1138346e0b17d900c4865d46d894e2add.tar.gz org.eclipse.xpand-232e41d1138346e0b17d900c4865d46d894e2add.tar.xz org.eclipse.xpand-232e41d1138346e0b17d900c4865d46d894e2add.zip |
java typesystem tests added
2 files changed, 27 insertions, 1 deletions
diff --git a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/analyzation/typesystem/java/GenericsBean.java b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/analyzation/typesystem/java/GenericsBean.java index cb70ab33..60021b62 100644 --- a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/analyzation/typesystem/java/GenericsBean.java +++ b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/analyzation/typesystem/java/GenericsBean.java @@ -28,5 +28,9 @@ public class GenericsBean<T, L extends Comparable<T>> implements Comparable<L>{ public static <X extends GenericsBean<String, String>> X doStuff(String a, X b) { return null; } + + { + GenericsBean<String, String> doStuff = doStuff("", new GenericsBean<String, String>()); + } } diff --git a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystemTest.java b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystemTest.java index e8701418..6cf2773d 100644 --- a/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystemTest.java +++ b/tests/org.eclipse.xpand3.tests/src/org/eclipse/xpand3/analyzation/typesystem/java/JavaTypeSystemTest.java @@ -18,12 +18,15 @@ package org.eclipse.xpand3.analyzation.typesystem.java; import junit.framework.TestCase; import org.eclipse.emf.common.util.EList; +import org.eclipse.xpand3.analyzation.GenericsUtil; import org.eclipse.xpand3.analyzation.TypeSystem; import org.eclipse.xpand3.analyzation.TypeSystemFactory; import org.eclipse.xpand3.staticTypesystem.AbstractTypeReference; +import org.eclipse.xpand3.staticTypesystem.DeclaredFunction; import org.eclipse.xpand3.staticTypesystem.DeclaredProperty; import org.eclipse.xpand3.staticTypesystem.DeclaredStaticProperty; import org.eclipse.xpand3.staticTypesystem.DeclaredType; +import org.eclipse.xpand3.staticTypesystem.DeclaredTypeParameter; import org.eclipse.xpand3.staticTypesystem.Type; /** @@ -65,7 +68,7 @@ public class JavaTypeSystemTest extends TestCase { assertEquals(declaredType, staticProperty.getType().getDeclaredType()); } - public void testGenerics() throws Exception { + public void testGenericTypes() throws Exception { TypeSystem typeSystem = factory.getTypeSystem(GenericsBean.class .getName()); DeclaredType declaredType = typeSystem.typeForName(GenericsBean.class @@ -74,4 +77,23 @@ public class JavaTypeSystemTest extends TestCase { EList<AbstractTypeReference> superTypes = declaredType.getSuperTypes(); assertEquals(1,superTypes.size()); } + + public void testGenericMethods() throws Exception { + TypeSystem typeSystem = factory.getTypeSystem(GenericsBean.class + .getName()); + DeclaredType typeForName = typeSystem.typeForName("String"); + Type typeRef = GenericsUtil.typeRef(typeForName); + DeclaredFunction declaredFunction = typeSystem.functionForName("compareTo", typeRef, typeRef); + assertNotNull(declaredFunction); + + declaredFunction = typeSystem.functionForName("doStuff", typeRef, typeRef); + assertNotNull(declaredFunction); + EList<DeclaredTypeParameter> declaredTypeParameters = declaredFunction.getDeclaredTypeParameters(); + assertEquals(1,declaredTypeParameters.size()); + DeclaredTypeParameter typeParameter = declaredTypeParameters.get(0); + assertEquals("X",typeParameter.getName()); + assertEquals(1,typeParameter.getUpperBounds().size()); + Type t = (Type) typeParameter.getUpperBounds().get(0); + assertEquals(typeSystem.typeForName(GenericsBean.class.getSimpleName()), t.getDeclaredType()); + } } |