mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Tests of type unification for generic classes
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user