Examples of ErrorBuffer


Examples of org.stringtemplate.v4.misc.ErrorBuffer

        String templates =
            "foo() ::= \"hi <name:{[<aaa.bb!>]}> mom\"\n";
        writeFile(tmpdir, "t.stg", templates);

    STGroupFile group = null;
    STErrorListener errors = new ErrorBuffer();
    group = new STGroupFile(tmpdir+"/"+"t.stg");
    group.setListener(errors);
    group.load(); // force load
    String expected = "t.stg 1:29: '!' came as a complete surprise to me"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.misc.ErrorBuffer

    String templates =
      "foo() ::= \"hi <name\"";
    writeFile(tmpdir, "t.stg", templates);

    STGroupFile group = null;
    STErrorListener errors = new ErrorBuffer();
    group = new STGroupFile(tmpdir+"/"+"t.stg");
    group.setListener(errors);
    group.load(); // force load
    String expected = "t.stg 1:19: premature EOF"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.misc.ErrorBuffer

    String templates =
      "foo() ::= \"hi <name:{x|[<aaa.bb>]}\"\n";
    writeFile(tmpdir, "t.stg", templates);

    STGroupFile group = null;
    STErrorListener errors = new ErrorBuffer();
    group = new STGroupFile(tmpdir+"/"+"t.stg");
    group.setListener(errors);
    group.load(); // force load
    String expected = "t.stg 1:34: premature EOF"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.misc.ErrorBuffer

    String templates =
      "foo() ::= << <f(\"foo>>\n";
    writeFile(tmpdir, "t.stg", templates);

    STGroupFile group = null;
    STErrorListener errors = new ErrorBuffer();
    group = new STGroupFile(tmpdir+"/"+"t.stg");
    group.setListener(errors);
    group.load(); // force load
    String expected = "t.stg 1:20: EOF in string"+newline +
              "t.stg 1:20: premature EOF"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.misc.ErrorBuffer

    String templates =
      "foo() ::= << <!foo> >>";
    writeFile(tmpdir, "t.stg", templates);

    STGroupFile group = null;
    STErrorListener errors = new ErrorBuffer();
    group = new STGroupFile(tmpdir+"/"+"t.stg");
    group.setListener(errors);
    group.load(); // force load
    String expected =
      "t.stg 1:20: Nonterminated comment starting at 1:1: '!>' missing" +newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.misc.ErrorBuffer

    String templates =
      "foo() ::= \"hi <foo(>\"\n";
    writeFile(tmpdir, "t.stg", templates);

    STGroupFile group = null;
    STErrorListener errors = new ErrorBuffer();
    group = new STGroupFile(tmpdir+"/"+"t.stg");
    group.setListener(errors);
    group.load(); // force load
    String expected = "t.stg 1:19: '>' came as a complete surprise to me"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.misc.ErrorBuffer

    String templates =
      "foo() ::= \"<a,b:t(),u()>\"\n";
    writeFile(tmpdir, "t.stg", templates);

    STGroupFile group = null;
    STErrorListener errors = new ErrorBuffer();
    group = new STGroupFile(tmpdir+"/"+"t.stg");
    group.setListener(errors);
    group.load(); // force load
    String expected = "t.stg 1:19: mismatched input ',' expecting RDELIM"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.misc.ErrorBuffer

  @Test
  public void testHandleBuggyDefaultArgument() throws Exception {
    String templates = "main(a={(<\"\")>}) ::= \"\"";
    writeFile(tmpdir, "t.stg", templates);

    final ErrorBuffer errors = new ErrorBuffer();
    STGroup group = new STGroupFile(tmpdir + "/t.stg");
    group.setListener(errors);

    ST st = group.getInstanceOf("main");
    String s = st.render();

    // Check the errors. This contained an "NullPointerException" before
    Assert.assertEquals(
        "t.stg 1:12: mismatched input ')' expecting RDELIM"+newline,
        errors.toString());
  }
View Full Code Here

Examples of org.stringtemplate.v4.misc.ErrorBuffer

    "a() ::= \"a: <b()>\"\n";
    writeFile(dir, "group.stg", groupFile);
    String importedFile =
      "b() ::= \"b\"\n";
    writeFile(dir, "imported.stg", importedFile);
    STErrorListener errors = new ErrorBuffer();
    STGroup group = new STGroupDir(dir);
    group.setListener(errors);
    group.getInstanceOf("/group/a");
    String result = errors.toString();
    String expecting =
      "import illegal in group files embedded in STGroupDirs; import \"imported.stg\" in STGroupDir";
    assertTrue(result.contains(expecting));
  }
View Full Code Here

Examples of org.stringtemplate.v4.misc.ErrorBuffer

public class TestSyntaxErrors extends BaseTest {
    @Test public void testEmptyExpr() throws Exception {
        String template = " <> ";
        STGroup group = new STGroup();
    ErrorBuffer errors = new ErrorBuffer();
    group.setListener(errors);
    try {
          group.defineTemplate("test", template);
    }
    catch (STException se) {
      assert false;
    }
    String result = errors.toString();
        String expected = "test 1:0: this doesn't look like a template: \" <> \""+newline;
        assertEquals(expected, result);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.