use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.
the class IsNonnullFunctionTest method testComputeForPySrc.
@Test
public void testComputeForPySrc() {
IsNonnullFunction isNonnullFunction = new IsNonnullFunction();
PyExpr expr = new PyExpr("data", Integer.MAX_VALUE);
assertThat(isNonnullFunction.computeForPySrc(ImmutableList.of(expr))).isEqualTo(new PyExpr("data is not None", PyExprUtils.pyPrecedenceForOperator(Operator.NOT_EQUAL)));
}
use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.
the class KeysFunctionTest method testComputeForPySrc.
@Test
public void testComputeForPySrc() {
KeysFunction keysFunction = new KeysFunction();
PyExpr dict = new PyExpr("dictionary", Integer.MAX_VALUE);
assertThat(keysFunction.computeForPySrc(ImmutableList.of(dict))).isEqualTo(new PyListExpr("(dictionary).keys()", Integer.MAX_VALUE));
}
use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.
the class LengthFunctionTest method testComputeForPySrc.
@Test
public void testComputeForPySrc() {
LengthFunction lengthFunction = new LengthFunction();
PyExpr expr = new PyExpr("data", Integer.MAX_VALUE);
assertThat(lengthFunction.computeForPySrc(ImmutableList.of(expr))).isEqualTo(new PyExpr("len(data)", Integer.MAX_VALUE));
}
use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.
the class MaxFunctionTest method testComputeForPySrc.
@Test
public void testComputeForPySrc() {
MaxFunction maxFunction = new MaxFunction();
PyExpr expr0 = new PyExpr("number0", Integer.MAX_VALUE);
PyExpr expr1 = new PyExpr("number1", Integer.MAX_VALUE);
assertThat(maxFunction.computeForPySrc(ImmutableList.of(expr0, expr1))).isEqualTo(new PyExpr("max(number0, number1)", Integer.MAX_VALUE));
}
use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.
the class BidiEndEdgeFunctionTest method testComputeForPySrc.
@Test
public void testComputeForPySrc() {
BidiEndEdgeFunction codeSnippet = new BidiEndEdgeFunction(SharedRestrictedTestUtils.BIDI_GLOBAL_DIR_FOR_PY_ISRTL_CODE_SNIPPET_PROVIDER);
assertThat(codeSnippet.computeForPySrc(ImmutableList.<PyExpr>of())).isEqualTo(new PyExpr("'left' if (-1 if IS_RTL else 1) < 0 else 'right'", PyExprUtils.pyPrecedenceForOperator(Operator.CONDITIONAL)));
}
Aggregations