type inference for closures in groovy1.8
[idea/community.git] / plugins / groovy / test / org / jetbrains / plugins / groovy / lang / resolve / TypeInferenceTest.java
index 114a6b5dc10d559386cafec8a2f189b4c0fc4910..51513f30e03b8089f51f7cb1e29f2d7652165f4f 100644 (file)
@@ -15,9 +15,7 @@
  */
 package org.jetbrains.plugins.groovy.lang.resolve;
 
-import com.intellij.psi.CommonClassNames;
-import com.intellij.psi.PsiIntersectionType;
-import com.intellij.psi.PsiType;
+import com.intellij.psi.*;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType;
 import org.jetbrains.plugins.groovy.util.TestUtils;
@@ -142,4 +140,16 @@ public class TypeInferenceTest extends GroovyResolveTestCase {
   public void testRawTypeInReturnExpression() {
     assertNotNull(resolve("A.groovy"));
   }
+
+  private void assertTypeEquals(String expected, String fileName) {
+    final PsiReference ref = configureByFile(getTestName(true) + "/" + fileName);
+    assertInstanceOf(ref, GrReferenceExpression.class);
+    final PsiType type = ((GrReferenceExpression)ref).getType();
+    assertNotNull(type);
+    assertEquals(expected, type.getCanonicalText());
+  }
+
+  public void testTypeOfGroupBy() {
+    assertTypeEquals("java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>>", "A.groovy");
+  }
 }