use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.
the class FloorFunctionTest method testComputeForPySrc.
@Test
public void testComputeForPySrc() {
FloorFunction floorFunction = new FloorFunction();
PyExpr expr = new PyExpr("number", Integer.MAX_VALUE);
assertThat(floorFunction.computeForPySrc(ImmutableList.of(expr))).isEqualTo(new PyExpr("int(math.floor(number))", Integer.MAX_VALUE));
}
use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.
the class MinFunctionTest method testComputeForPySrc.
@Test
public void testComputeForPySrc() {
MinFunction minFunction = new MinFunction();
PyExpr expr0 = new PyExpr("number0", Integer.MAX_VALUE);
PyExpr expr1 = new PyExpr("number1", Integer.MAX_VALUE);
assertThat(minFunction.computeForPySrc(ImmutableList.of(expr0, expr1))).isEqualTo(new PyExpr("min(number0, number1)", Integer.MAX_VALUE));
}
use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.
the class StrIndexOfFunctionTest method testComputeForPySrc_stringInput.
@Test
public void testComputeForPySrc_stringInput() {
StrIndexOfFunction strIndexOf = new StrIndexOfFunction();
PyExpr base = new PyStringExpr("'foobar'", Integer.MAX_VALUE);
PyExpr substring = new PyStringExpr("'bar'", Integer.MAX_VALUE);
assertThat(strIndexOf.computeForPySrc(ImmutableList.of(base, substring))).isEqualTo(new PyExpr("('foobar').find('bar')", Integer.MAX_VALUE));
}
use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.
the class StrIndexOfFunctionTest method testComputeForPySrc_nonStringInput.
@Test
public void testComputeForPySrc_nonStringInput() {
StrIndexOfFunction strIndexOf = new StrIndexOfFunction();
PyExpr base = new PyExpr("foobar", Integer.MAX_VALUE);
PyExpr substring = new PyExpr("bar", Integer.MAX_VALUE);
assertThat(strIndexOf.computeForPySrc(ImmutableList.of(base, substring))).isEqualTo(new PyExpr("(str(foobar)).find(str(bar))", Integer.MAX_VALUE));
}
use of com.google.template.soy.pysrc.restricted.PyExpr in project closure-templates by google.
the class ChangeNewlineToBrDirectiveTest method testApplyForPySrc.
@Test
public void testApplyForPySrc() {
ChangeNewlineToBrDirective directive = new ChangeNewlineToBrDirective();
PyExpr data = new PyExpr("'data'", Integer.MAX_VALUE);
assertThat(directive.applyForPySrc(data, ImmutableList.<PyExpr>of()).getText()).isEqualTo("sanitize.change_newline_to_br('data')");
}
Aggregations