Package org.stringtemplate.v4.misc

Examples of org.stringtemplate.v4.misc.ErrorBuffer


  }

    @Test public void testSetUnknownAttr() throws Exception {
        String templates =
            "t() ::= <<hi <name>!>>\n";
        ErrorBuffer errors = new ErrorBuffer();
        writeFile(tmpdir, "t.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
    group.setListener(errors);
        ST st = group.getInstanceOf("t");
        String result = null;
View Full Code Here


        String templates =
                "typeInit ::= [\"int\":\"0\", default:] "+newline+
                "var(type,name) ::= \"<type> <name> = <typeInit.(type)>;\""+newline
                ;
        writeFile(tmpdir, "test.stg", templates);
        ErrorBuffer errors = new ErrorBuffer();
        STGroupFile group = new STGroupFile(tmpdir+"/"+"test.stg");
    group.setListener(errors);
        group.load();
        String expected = "[test.stg 1:33: missing value for key at ']']";
        String result = errors.errors.toString();
View Full Code Here

        String g = "a() ::= <<[<@r>foo<@end>]>>\n"+
                   "@a.r() ::= <<bar>>\n"; // error; dup
        writeFile(dir, "g.stg", g);

        STGroupFile group = new STGroupFile(dir+"/g.stg");
        ErrorBuffer errors = new ErrorBuffer();
        group.setListener(errors);
        group.load();
        String expected = "g.stg 2:3: region /a.r is embedded and thus already implicitly defined"+newline;
        String result = errors.toString();
        assertEquals(expected, result);
    }
View Full Code Here

      "]\n" +
      ">>\n"; // error; dup
    writeFile(dir, "g.stg", g);

    STGroupFile group = new STGroupFile(dir+"/g.stg");
    ErrorBuffer errors = new ErrorBuffer();
    group.setListener(errors);
    group.load();
    String expected = "g.stg 3:2: redefinition of region /a.r"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

    String dir = getRandomDir();
    String g = "@t.() ::= \"\"\n";
    writeFile(dir, "g.stg", g);

    STGroupFile group = new STGroupFile(dir+"/g.stg");
    ErrorBuffer errors = new ErrorBuffer();
    group.setListener(errors);
    group.load();
    String expected = "g.stg 1:3: missing ID at '('"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

        String g =
                "a() ::= <<\n" +
                "X<@r()>Y\n" +
                ">>\n"+
                "@a.q() ::= \"foo\"" +newline;
        STErrorListener errors = new ErrorBuffer();
        writeFile(dir, "g.stg", g);
        STGroupFile group = new STGroupFile(dir+"/g.stg");
    group.setListener(errors);
        ST st = group.getInstanceOf("a");
        st.render();
        String result = errors.toString();
        String expecting = "g.stg 4:3: template /a doesn't have a region called q"+newline;
        assertEquals(expecting, result);
    }
View Full Code Here

        writeFile(dir, "g.stg", g);
        STGroupFile group = new STGroupFile(dir+"/g.stg");

        String sub =
            "@a.r() ::= \"A<@super.q()>B\"" +newline; // allow this; trap at runtime
        STErrorListener errors = new ErrorBuffer();
        group.setListener(errors);
        writeFile(dir, "sub.stg", sub);
        STGroupFile subGroup = new STGroupFile(dir+"/sub.stg");
        subGroup.importTemplates(group);
View Full Code Here

        String dir = getRandomDir();
        String groupFile =
            "b() ::= \"bar\"\n"+
            "b() ::= \"duh\"\n";
        writeFile(dir, "group.stg", groupFile);
    STErrorListener errors = new ErrorBuffer();
        STGroupFile group = new STGroupFile(dir+"/group.stg");
    group.setListener(errors);
        group.load();
    String expected = "group.stg 2:0: redefinition of template b"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
    }
View Full Code Here

      "g() ::= \"<f(x={a},z={b})>\"";
       //012345678901234567

    writeFile(dir, "group.stg", groupFile);
    STGroupFile group = new STGroupFile(dir+"/group.stg");
    ErrorBuffer errors = new ErrorBuffer();
    group.setListener(errors);
    ST st = group.getInstanceOf("g");
    st.render();
    String expected = "context [/g] 1:1 attribute z isn't defined"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

      "g() ::= \"<f(x={a},{b})>\"";
       //01234567890123456789

    writeFile(dir, "group.stg", groupFile);
    STGroupFile group = new STGroupFile(dir+"/group.stg");
    ErrorBuffer errors = new ErrorBuffer();
    group.setListener(errors);
    group.load();
    String expected = "group.stg 2:18: mismatched input '{' expecting ELLIPSIS"+newline;
    String result = errors.toString();
    assertEquals(expected, result);
  }
View Full Code Here

TOP

Related Classes of org.stringtemplate.v4.misc.ErrorBuffer

Copyright © 2018 www.massapicom. 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.