From 532ae5f155725f6bdcb2b2ba32faab64889d0b0a Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Thu, 21 Aug 2014 14:50:45 +0400 Subject: [PATCH] Tests of type unification for generic classes --- .../com/jetbrains/python/PyTypeTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/python/testSrc/com/jetbrains/python/PyTypeTest.java b/python/testSrc/com/jetbrains/python/PyTypeTest.java index b0e41bcffddc..b6ed1090edad 100644 --- a/python/testSrc/com/jetbrains/python/PyTypeTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypeTest.java @@ -835,6 +835,37 @@ public class PyTypeTest extends PyTestCase { "expr = (1,) + (True, 'spam') + ()"); } + public void testConstructorUnification() { + doTest("C[int]", + "class C(object):\n" + + " def __init__(self, x):\n" + + " '''\n" + + " :type x: T\n" + + " :rtype: C[T]\n" + + " '''\n" + + " pass\n" + + "\n" + + "expr = C(10)\n"); + } + + public void testGenericClassMethodUnification() { + doTest("int", + "class C(object):\n" + + " def __init__(self, x):\n" + + " '''\n" + + " :type x: T\n" + + " :rtype: C[T]\n" + + " '''\n" + + " pass\n" + + " def foo(self):\n" + + " '''\n" + + " :rtype: T\n" + + " '''\n" + + " pass\n" + + "\n" + + "expr = C(10).foo()\n"); + } + private static TypeEvalContext getTypeEvalContext(@NotNull PyExpression element) { return TypeEvalContext.userInitiated(element.getContainingFile()).withTracing(); }