void isNotValidExpressionList() {
   FormattingErrorReporter errorReporter = new FormattingErrorReporter();
   expressionParser(errorReporter).parseExpressionList();
   if (errorReporter.getErrorMessages().isEmpty()) {
     fail("is an invalid expression list");
   }
 }
 void isNotValidVar() {
   FormattingErrorReporter errorReporter = new FormattingErrorReporter();
   expressionParser(errorReporter).parseVariable();
   if (errorReporter.getErrorMessages().isEmpty()) {
     fail("is an invalid var");
   }
 }
 ExprNode isValidExpression() {
   FormattingErrorReporter errorReporter = new FormattingErrorReporter();
   ExprNode expr = expressionParser(errorReporter).parseExpression();
   if (!errorReporter.getErrorMessages().isEmpty()) {
     fail("is a valid expression", errorReporter.getErrorMessages());
   }
   return expr;
 }
 void isNotValidGlobal() {
   FormattingErrorReporter errorReporter = new FormattingErrorReporter();
   ExprNode expr = expressionParser(errorReporter).parseExpression();
   ImmutableList<String> errorMessages = errorReporter.getErrorMessages();
   if (expr instanceof GlobalNode && errorMessages.isEmpty()) {
     fail("is an invalid global");
   }
 }
 void isValidGlobal() {
   FormattingErrorReporter errorReporter = new FormattingErrorReporter();
   ExprNode expr = expressionParser(errorReporter).parseExpression();
   Truth.assertThat(expr).isInstanceOf(GlobalNode.class);
   if (!errorReporter.getErrorMessages().isEmpty()) {
     fail("is a valid global", errorReporter.getErrorMessages());
   }
 }
 List<ExprNode> isValidExpressionList() {
   FormattingErrorReporter errorReporter = new FormattingErrorReporter();
   List<ExprNode> exprList = expressionParser(errorReporter).parseExpressionList();
   if (!errorReporter.getErrorMessages().isEmpty()) {
     fail("is a valid expression list", errorReporter.getErrorMessages());
   }
   return exprList;
 }
  void isValidVarNamed(String name) {
    FormattingErrorReporter errorReporter = new FormattingErrorReporter();
    VarNode varNode = expressionParser(errorReporter).parseVariable();
    assertThat(errorReporter.getErrorMessages()).isEmpty();

    String actualName = varNode.getName();
    if (!actualName.equals(name)) {
      failWithBadResults("is var named", name, "is named", actualName);
    }
    if (!varNode.toSourceString().equals("$" + name)) {
      failWithBadResults("has sourceString", "$" + name, "is named", varNode.toSourceString());
    }
  }
 public void testMapLiteralAsRecord_duplicateKeys() {
   SoyFileSetNode soyTree =
       SoyFileSetParserBuilder.forFileContents(
               constructTemplateSource("{let $map: ['a': 1, 'a': 2]/}"))
           .declaredSyntaxVersion(SyntaxVersion.V2_0)
           .doRunInitialParsingPasses(false)
           .typeRegistry(typeRegistry)
           .parse()
           .fileSet();
   createResolveNamesVisitorForMaxSyntaxVersion().exec(soyTree);
   FormattingErrorReporter reporter = new FormattingErrorReporter();
   new ResolveExpressionTypesVisitor(typeRegistry, SyntaxVersion.V9_9, reporter).exec(soyTree);
   assertThat(Iterables.getOnlyElement(reporter.getErrorMessages()))
       .isEqualTo("Record literals with duplicate keys are not allowed.  Duplicate key: 'a'");
 }
 void isValidGlobalNamed(String name) {
   FormattingErrorReporter errorReporter = new FormattingErrorReporter();
   GlobalNode globalNode = (GlobalNode) expressionParser(errorReporter).parseExpression();
   if (!errorReporter.getErrorMessages().isEmpty()) {
     fail("is valid global", errorReporter.getErrorMessages());
   }
   String actualName = globalNode.getName();
   if (!actualName.equals(name)) {
     failWithBadResults("is global named", name, "has name", actualName);
   }
   String actualSourceString = globalNode.toSourceString();
   if (!actualSourceString.equals(name)) {
     failWithBadResults("is global named", name, "has source string", actualSourceString);
   }
 }