Search in sources :

Example 46 with SoyValue

use of com.google.template.soy.data.SoyValue in project closure-templates by google.

the class StrContainsFunctionTest method testComputeForJava_containsString.

@Test
public void testComputeForJava_containsString() {
    StrContainsFunction strContains = new StrContainsFunction();
    SoyValue arg0 = StringData.forValue("foobarfoo");
    SoyValue arg1 = StringData.forValue("bar");
    assertThat(strContains.computeForJava(ImmutableList.of(arg0, arg1))).isEqualTo(BooleanData.TRUE);
}
Also used : SoyValue(com.google.template.soy.data.SoyValue) Test(org.junit.Test)

Example 47 with SoyValue

use of com.google.template.soy.data.SoyValue in project closure-templates by google.

the class StrLenFunctionTest method testComputeForJava_containsSanitizedContent.

@Test
public void testComputeForJava_containsSanitizedContent() {
    StrLenFunction strLen = new StrLenFunction();
    SoyValue arg0 = ordainAsSafe("foobarfoo", ContentKind.TEXT);
    assertThat(strLen.computeForJava(ImmutableList.of(arg0))).isEqualTo(IntegerData.forValue(9));
}
Also used : SoyValue(com.google.template.soy.data.SoyValue) Test(org.junit.Test)

Example 48 with SoyValue

use of com.google.template.soy.data.SoyValue in project closure-templates by google.

the class BidiTextDirFunctionTest method testComputeForJava.

@Test
public void testComputeForJava() {
    BidiTextDirFunction bidiTextDirFunction = new BidiTextDirFunction();
    SoyValue text = StringData.EMPTY_STRING;
    assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.ZERO);
    text = StringData.forValue("a");
    assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.ONE);
    text = StringData.forValue("\u05E0");
    assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.MINUS_ONE);
    text = SanitizedContents.unsanitizedText("a");
    assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.ONE);
    text = SanitizedContents.unsanitizedText("a", Dir.LTR);
    assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.ONE);
    text = SanitizedContents.unsanitizedText("a", Dir.RTL);
    assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.MINUS_ONE);
    text = SanitizedContents.unsanitizedText("a", Dir.NEUTRAL);
    assertThat(bidiTextDirFunction.computeForJava(ImmutableList.of(text))).isEqualTo(IntegerData.ZERO);
}
Also used : SoyValue(com.google.template.soy.data.SoyValue) Test(org.junit.Test)

Example 49 with SoyValue

use of com.google.template.soy.data.SoyValue in project closure-templates by google.

the class CeilingFunctionTest method testComputeForJava.

@Test
public void testComputeForJava() {
    CeilingFunction ceilingFunction = new CeilingFunction();
    SoyValue float0 = FloatData.forValue(7.5);
    assertThat(ceilingFunction.computeForJava(ImmutableList.of(float0))).isEqualTo(IntegerData.forValue(8));
    SoyValue integer = IntegerData.forValue(14);
    assertThat(ceilingFunction.computeForJava(ImmutableList.of(integer))).isEqualTo(IntegerData.forValue(14));
}
Also used : SoyValue(com.google.template.soy.data.SoyValue) Test(org.junit.Test)

Example 50 with SoyValue

use of com.google.template.soy.data.SoyValue in project closure-templates by google.

the class LengthFunctionTest method testComputeForJava.

@Test
public void testComputeForJava() {
    LengthFunction lengthFunction = new LengthFunction();
    SoyValue list = SoyValueConverterUtility.newList(1, 3, 5, 7);
    assertThat(lengthFunction.computeForJava(ImmutableList.of(list))).isEqualTo(IntegerData.forValue(4));
}
Also used : SoyValue(com.google.template.soy.data.SoyValue) Test(org.junit.Test)

Aggregations

SoyValue (com.google.template.soy.data.SoyValue)61 Test (org.junit.Test)31 StringData (com.google.template.soy.data.restricted.StringData)5 ExprNode (com.google.template.soy.exprtree.ExprNode)4 SoyLegacyObjectMap (com.google.template.soy.data.SoyLegacyObjectMap)3 SoyList (com.google.template.soy.data.SoyList)3 ParentExprNode (com.google.template.soy.exprtree.ExprNode.ParentExprNode)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 SanitizedContentKind (com.google.template.soy.base.internal.SanitizedContentKind)2 SanitizedContent (com.google.template.soy.data.SanitizedContent)2 ContentKind (com.google.template.soy.data.SanitizedContent.ContentKind)2 SoyDataException (com.google.template.soy.data.SoyDataException)2 SoyDict (com.google.template.soy.data.SoyDict)2 SoyRecord (com.google.template.soy.data.SoyRecord)2 FloatData (com.google.template.soy.data.restricted.FloatData)2 IntegerData (com.google.template.soy.data.restricted.IntegerData)2 SoyString (com.google.template.soy.data.restricted.SoyString)2 UndefinedData (com.google.template.soy.data.restricted.UndefinedData)2 ExprRootNode (com.google.template.soy.exprtree.ExprRootNode)2 SoyPrintDirective (com.google.template.soy.shared.restricted.SoyPrintDirective)2