antlr / stringtemplate4

StringTemplate 4
http://www.stringtemplate.org
Other
956 stars 231 forks source link

Template imports ignore UTF-8 setting #205

Closed kkress2000 closed 6 years ago

kkress2000 commented 6 years ago

Test:

@Test public void testImportUtfTemplateFileSameDir() throws Exception {
    /*
    dir
        group1.stg      (that imports c.st)
        c.st
     */
    String dir = getRandomDir();
    String groupFile =
        "import \"c.st\"\n" +
        "a() ::= \"g1 a\"\n"+
        "b() ::= \"<c()>\"\n";
    writeFile(dir, "group1.stg", groupFile);
    writeFile(dir, "c.st", "c() ::= \"2∏r\"\n");

    STGroup group1 = new STGroupFile(dir+"/group1.stg");
    ST st = group1.getInstanceOf("c"); // should see c()
    String expected = "2∏r";
    String result = st.render();
    assertEquals(expected, result);
}
parrt commented 6 years ago

This is working for me, @kkress2000:

@Test public void testImportUtfTemplateFileSameDir() throws Exception {
        /*
        dir
            group.stg       (that imports c.st)
            c.st
         */
        String dir = getRandomDir();
        String groupFile =
            "import \"c.st\"\n" +
            "a() ::= \"g1 a\"\n"+
            "b() ::= \"<c()>\"\n";
        writeFile(dir, "group.stg", groupFile);
        writeFile(dir, "c.st", "c() ::= \"2∏r\"\n");

        STGroup group1 = new STGroupFile(dir+"/group.stg");
        ST st = group1.getInstanceOf("c"); // should see c()
        String expected = "2∏r";
        String result = st.render();
        assertEquals(expected, result);
    }