use of com.jetbrains.python.psi.PyTargetExpression in project intellij-community by JetBrains.
the class PyAssignmentMappingTest method testMultiple.
public void testMultiple() throws Exception {
Map<String, PsiElement> marks = loadTest();
final int TARGET_NUM = 3;
Assert.assertEquals(TARGET_NUM + 1, marks.size());
// const -> expr;
PsiElement src = marks.get("<src>").getParent();
PsiElement[] dsts = new PsiElement[TARGET_NUM];
for (int i = 0; i < TARGET_NUM; i += 1) {
// ident -> target expr
PsiElement dst = marks.get("<dst" + String.valueOf(i + 1) + ">").getParent();
Assert.assertTrue(dst instanceof PyTargetExpression);
dsts[i] = dst;
}
PyAssignmentStatement stmt = (PyAssignmentStatement) src.getParent();
List<Pair<PyExpression, PyExpression>> mapping = stmt.getTargetsToValuesMapping();
Assert.assertEquals(TARGET_NUM, mapping.size());
for (int i = 0; i < TARGET_NUM; i += 1) {
Pair<PyExpression, PyExpression> pair = mapping.get(i);
Assert.assertEquals(dsts[i], pair.getFirst());
Assert.assertEquals(src, pair.getSecond());
}
}
Aggregations