use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testFunction.
public void testFunction() {
PyBlockEvaluator eval = new PyBlockEvaluator();
PyFile file = (PyFile) PsiFileFactory.getInstance(myFixture.getProject()).createFileFromText("a.py", PythonFileType.INSTANCE, "def foo(): return 'a'");
PyFunction foo = file.findTopLevelFunction("foo");
eval.evaluate(foo);
assertEquals("a", eval.getReturnValue());
}
use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testDictNoEvaluate.
public void testDictNoEvaluate() {
PyBlockEvaluator eval = doEvaluate("a={'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 testVar.
public void testVar() {
PyBlockEvaluator eval = doEvaluate("a='b'\nc='d'\ne=a+c");
assertEquals("bd", eval.getValue("e"));
}
use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testAugAssign.
public void testAugAssign() {
PyBlockEvaluator eval = doEvaluate("a='b'\na+='c'");
assertEquals("bc", eval.getValue("a"));
}
use of com.jetbrains.python.psi.impl.blockEvaluator.PyBlockEvaluator in project intellij-community by JetBrains.
the class PyBlockEvaluatorTest method testDictUpdate.
public void testDictUpdate() {
PyBlockEvaluator eval = doEvaluate("a={}\na.update({'b': 'c'})");
Map map = (Map) eval.getValue("a");
assertEquals(1, map.size());
assertEquals("c", map.get("b"));
}
Aggregations