Package org.stringtemplate.v4

Examples of org.stringtemplate.v4.STGroupDir


        // new output dir for each test
        tmpdir = new File(System.getProperty("java.io.tmpdir"),
              "antlr-"+getClass().getName()+"-"+
              System.currentTimeMillis()).getAbsolutePath();
        ErrorManager.resetErrorState();
        STGroup.defaultGroup = new STGroup();
    }
View Full Code Here


    return getBadWords().contains(idNode.getText());
  }

  @Override
  protected STGroup loadTemplates() {
    STGroup result = targetTemplates.get();
    if (result == null) {
      result = super.loadTemplates();
      result.registerRenderer(String.class, new JavaStringRenderer(), true);
      targetTemplates.set(result);
    }

    return result;
  }
View Full Code Here

public class TestGroups extends BaseTest {
  @Test public void testSimpleGroup() throws Exception {
    String dir = getRandomDir();
    writeFile(dir, "a.st", "a(x) ::= <<foo>>");
    STGroup group = new STGroupDir(dir);
    ST st = group.getInstanceOf("a");
    String expected = "foo";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

  }

  @Test public void testEscapeOneRightAngle() throws Exception {
    String dir = getRandomDir();
    writeFile(dir, "a.st", "a(x) ::= << > >>");
    STGroup group = new STGroupDir(dir);
    ST st = group.getInstanceOf("a");
    st.add("x", "parrt");
    String expected = " > ";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

  }

  @Test public void testEscapeJavaRightShift() throws Exception {
    String dir = getRandomDir();
    writeFile(dir, "a.st", "a(x) ::= << \\>> >>");
    STGroup group = new STGroupDir(dir);
    ST st = group.getInstanceOf("a");
    st.add("x", "parrt");
    String expected = " >> ";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

  }

  @Test public void testEscapeJavaRightShift2() throws Exception {
    String dir = getRandomDir();
    writeFile(dir, "a.st", "a(x) ::= << >\\> >>");
    STGroup group = new STGroupDir(dir);
    ST st = group.getInstanceOf("a");
    st.add("x", "parrt");
    String expected = " >> ";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

  }

  @Test public void testEscapeJavaRightShiftAtRightEdge() throws Exception {
    String dir = getRandomDir();
    writeFile(dir, "a.st", "a(x) ::= <<\\>>>"); // <<\>>>
    STGroup group = new STGroupDir(dir);
    ST st = group.getInstanceOf("a");
    st.add("x", "parrt");
    String expected = "\\>";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

  }

  @Test public void testEscapeJavaRightShiftAtRightEdge2() throws Exception {
    String dir = getRandomDir();
    writeFile(dir, "a.st", "a(x) ::= <<>\\>>>");
    STGroup group = new STGroupDir(dir);
    ST st = group.getInstanceOf("a");
    st.add("x", "parrt");
    String expected = ">>";
    String result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

    @Test public void testGroupWithTwoTemplates() throws Exception {
        String dir = getRandomDir();
    writeFile(dir, "a.st", "a(x) ::= <<foo>>");
    writeFile(dir, "b.st", "b() ::= \"bar\"");
        STGroup group = new STGroupDir(dir);
        ST st1 = group.getInstanceOf("a");
        ST st2 = group.getInstanceOf("b");
        String expected = "foobar";
        String result = st1.render()+st2.render();
        assertEquals(expected, result);
    }
View Full Code Here

    @Test public void testSubdir() throws Exception {
        // /randomdir/a and /randomdir/subdir/b
        String dir = getRandomDir();
        writeFile(dir,           "a.st", "a(x) ::= <<foo>>");
    writeFile(dir+"/subdir", "b.st", "b() ::= \"bar\"");
        STGroup group = new STGroupDir(dir);
    assertEquals("foo", group.getInstanceOf("a").render());
    assertEquals("bar", group.getInstanceOf("/subdir/b").render());
    assertEquals("bar", group.getInstanceOf("subdir/b").render());
    }
View Full Code Here

TOP

Related Classes of org.stringtemplate.v4.STGroupDir

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.