use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testDictAssignNoEvaluate.
public void testDictAssignNoEvaluate() {
PyBlockEvaluator eval = doEvaluate("a={}\na['b']='c'", true);
Map map = (Map) eval.getValue("a");
assertEquals(1, map.size());
assertTrue(map.get("b") instanceof PyStringLiteralExpression);
}
use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testExtend.
public void testExtend() {
PyBlockEvaluator eval = doEvaluate("a=['b']\na.extend(['c'])");
List<String> list = eval.getValueAsStringList("a");
assertEquals(2, list.size());
assertEquals("b", list.get(0));
assertEquals("c", list.get(1));
}
use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method doEvaluate.
private PyBlockEvaluator doEvaluate(String text, boolean skipEvaluatingCollectionItems) {
PyBlockEvaluator eval = new PyBlockEvaluator();
if (skipEvaluatingCollectionItems) {
eval.setEvaluateCollectionItems(false);
}
PyFile file = (PyFile) PsiFileFactory.getInstance(myFixture.getProject()).createFileFromText("a.py", PythonFileType.INSTANCE, text);
eval.evaluate(file);
return eval;
}
use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testSimple.
public void testSimple() {
PyBlockEvaluator eval = doEvaluate("a='b'");
assertEquals("b", eval.getValue("a"));
}
use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testMixedList.
public void testMixedList() {
PyBlockEvaluator eval = doEvaluate("a=['b',['c','d']]");
List list = (List) eval.getValue("a");
assertEquals(2, list.size());
assertEquals("b", list.get(0));
assertEquals(new ArrayList<>(Arrays.asList("c", "d")), list.get(1));
}
Aggregations