mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Initial implementation of lists type inference (PY-1182)
This commit is contained in:
committed by
Elizaveta Shashkova
parent
adf85192a7
commit
cedb7bda67
@@ -1228,6 +1228,43 @@ public class PyTypeTest extends PyTestCase {
|
||||
TypeEvalContext.userInitiated(expr.getProject(), expr.getContainingFile()));
|
||||
}
|
||||
|
||||
// PY-1182
|
||||
public void testCollectionType() {
|
||||
doTest("List[int]",
|
||||
"def f():\n" +
|
||||
" expr = []\n" +
|
||||
" expr.append(42)\n" +
|
||||
" expr.append(0)"
|
||||
);
|
||||
|
||||
doTest("List[Union[str, int]]",
|
||||
"def f():\n" +
|
||||
" expr = []\n" +
|
||||
" expr.append('a')\n" +
|
||||
" expr.append(1)"
|
||||
);
|
||||
|
||||
doTest("List[Union[Union[int, str], Any]]",
|
||||
"expr = [3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4]\n" +
|
||||
"expr.append('a')"
|
||||
);
|
||||
|
||||
doTest("List[Union[int, str]]",
|
||||
"expr = [1, 2]\n" +
|
||||
"expr.append(42)\n" +
|
||||
"expr.extend(['a']"
|
||||
);
|
||||
|
||||
doTest("List[Union[int, str, None]]",
|
||||
"expr = []\n" +
|
||||
"expr.extend([1, 'a', None])"
|
||||
);
|
||||
|
||||
doTest("List[int]",
|
||||
"expr = []\n" +
|
||||
"expr.index(42)");
|
||||
}
|
||||
|
||||
// PY-20063
|
||||
public void testIteratedSetElement() {
|
||||
doTest("int",
|
||||
|
||||
Reference in New Issue
Block a user