Search in sources :

Example 36 with ExprNode

use of com.google.template.soy.exprtree.ExprNode in project closure-templates by google.

the class MsgSubstUnitBaseVarNameUtilsTest method assertErrorMsgWhenGenNoncollidingBaseNamesForExprs.

private void assertErrorMsgWhenGenNoncollidingBaseNamesForExprs(String expectedErrorMsg, String... exprTexts) {
    List<ExprNode> exprs = new ArrayList<>();
    for (String exprText : exprTexts) {
        exprs.add(parse(exprText));
    }
    ErrorReporter errorReporter = ErrorReporter.createForTest();
    MsgSubstUnitBaseVarNameUtils.genNoncollidingBaseNamesForExprs(exprs, "FALLBACK", errorReporter);
    assertThat(errorReporter.getErrors()).hasSize(1);
    assertThat(Iterables.getOnlyElement(errorReporter.getErrors()).message()).contains(expectedErrorMsg);
}
Also used : ExprNode(com.google.template.soy.exprtree.ExprNode) ErrorReporter(com.google.template.soy.error.ErrorReporter) ArrayList(java.util.ArrayList)

Example 37 with ExprNode

use of com.google.template.soy.exprtree.ExprNode in project closure-templates by google.

the class MsgSubstUnitBaseVarNameUtilsTest method assertCandidateBaseNamesForExpr.

private void assertCandidateBaseNamesForExpr(List<String> expected, String exprText) {
    ExprNode exprRoot = parse(exprText);
    List<String> actual = MsgSubstUnitBaseVarNameUtils.genCandidateBaseNamesForExpr(exprRoot);
    assertEquals(expected, actual);
}
Also used : ExprNode(com.google.template.soy.exprtree.ExprNode)

Example 38 with ExprNode

use of com.google.template.soy.exprtree.ExprNode in project closure-templates by google.

the class ExpressionSubject method isValidGlobal.

void isValidGlobal() {
    ExprNode expr = parseExpression();
    if (errorReporter.hasErrors()) {
        fail("is a valid global", errorReporter.getErrors());
    }
    Truth.assertThat(expr).named(actualAsString()).isInstanceOf(GlobalNode.class);
}
Also used : ExprNode(com.google.template.soy.exprtree.ExprNode)

Aggregations

ExprNode (com.google.template.soy.exprtree.ExprNode)38 ParentExprNode (com.google.template.soy.exprtree.ExprNode.ParentExprNode)7 IntegerNode (com.google.template.soy.exprtree.IntegerNode)7 StringNode (com.google.template.soy.exprtree.StringNode)7 FunctionNode (com.google.template.soy.exprtree.FunctionNode)5 Test (org.junit.Test)5 ImmutableList (com.google.common.collect.ImmutableList)4 SoyValue (com.google.template.soy.data.SoyValue)4 GlobalNode (com.google.template.soy.exprtree.GlobalNode)4 VarRefNode (com.google.template.soy.exprtree.VarRefNode)4 CodeChunk (com.google.template.soy.jssrc.dsl.CodeChunk)4 SoyType (com.google.template.soy.types.SoyType)4 LinkedHashMap (java.util.LinkedHashMap)4 AbstractParentExprNode (com.google.template.soy.exprtree.AbstractParentExprNode)3 FloatNode (com.google.template.soy.exprtree.FloatNode)3 SourceLocation (com.google.template.soy.base.SourceLocation)2 ErrorReporter (com.google.template.soy.error.ErrorReporter)2 BooleanNode (com.google.template.soy.exprtree.BooleanNode)2 PrimitiveNode (com.google.template.soy.exprtree.ExprNode.PrimitiveNode)2 ExprRootNode (com.google.template.soy.exprtree.ExprRootNode)2