use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class RoundFunctionTest method testComputeForJava.
@Test
public void testComputeForJava() {
RoundFunction roundFunction = new RoundFunction();
SoyValue float0 = FloatData.forValue(9753.141592653590);
assertThat(roundFunction.computeForJava(ImmutableList.of(float0))).isEqualTo(IntegerData.forValue(9753));
SoyValue numDigitsAfterPt = IntegerData.ZERO;
assertThat(roundFunction.computeForJava(ImmutableList.of(float0, numDigitsAfterPt))).isEqualTo(IntegerData.forValue(9753));
numDigitsAfterPt = IntegerData.forValue(4);
assertThat(roundFunction.computeForJava(ImmutableList.of(float0, numDigitsAfterPt))).isEqualTo(FloatData.forValue(9753.1416));
numDigitsAfterPt = IntegerData.forValue(-2);
assertThat(roundFunction.computeForJava(ImmutableList.of(float0, numDigitsAfterPt))).isEqualTo(IntegerData.forValue(9800));
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class StrIndexOfFunctionTest method testComputeForJava_containsString.
@Test
public void testComputeForJava_containsString() {
StrIndexOfFunction strIndexOf = new StrIndexOfFunction();
SoyValue arg0 = StringData.forValue("foobarfoo");
SoyValue arg1 = StringData.forValue("bar");
assertThat(strIndexOf.computeForJava(ImmutableList.of(arg0, arg1))).isEqualTo(IntegerData.forValue(3));
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class StrIndexOfFunctionTest method testComputeForJava_doesNotContainString.
@Test
public void testComputeForJava_doesNotContainString() {
StrIndexOfFunction strIndexOf = new StrIndexOfFunction();
SoyValue arg0 = StringData.forValue("foobarfoo");
SoyValue arg1 = StringData.forValue("baz");
assertThat(strIndexOf.computeForJava(ImmutableList.of(arg0, arg1))).isEqualTo(IntegerData.forValue(-1));
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class StrSubFunctionTest method testComputeForJava_noEndIndex.
@Test
public void testComputeForJava_noEndIndex() {
StrSubFunction strSub = new StrSubFunction();
SoyValue arg0 = StringData.forValue("foobarfoo");
SoyValue arg1 = IntegerData.forValue(2);
assertThat(strSub.computeForJava(ImmutableList.of(arg0, arg1))).isEqualTo(StringData.forValue("obarfoo"));
}
use of com.google.template.soy.data.SoyValue in project closure-templates by google.
the class StrSubFunctionTest method testComputeForJava_endIndex_SanitizedContent.
@Test
public void testComputeForJava_endIndex_SanitizedContent() {
StrSubFunction strSub = new StrSubFunction();
SoyValue arg0 = ordainAsSafe("foobarfoo", ContentKind.TEXT);
SoyValue arg1 = IntegerData.forValue(2);
SoyValue arg2 = IntegerData.forValue(7);
assertThat(strSub.computeForJava(ImmutableList.of(arg0, arg1, arg2))).isEqualTo(StringData.forValue("obarf"));
}
Aggregations