Examples of STGroupDir


Examples of org.stringtemplate.v4.STGroupDir

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

Examples of org.stringtemplate.v4.STGroupDir

  }

  @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

Examples of org.stringtemplate.v4.STGroupDir

  }

  @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

Examples of org.stringtemplate.v4.STGroupDir

  }

  @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

Examples of org.stringtemplate.v4.STGroupDir

  }

  @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

Examples of org.stringtemplate.v4.STGroupDir

  }

  @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

Examples of org.stringtemplate.v4.STGroupDir

    @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

Examples of org.stringtemplate.v4.STGroupDir

    @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

Examples of org.stringtemplate.v4.STGroupDir

  @Test public void testSubdirWithSubtemplate() throws Exception {
    // /randomdir/a and /randomdir/subdir/b
    String dir = getRandomDir();
    writeFile(dir+"/subdir", "a.st", "a(x) ::= \"<x:{y|<y>}>\"");
    STGroup group = new STGroupDir(dir);
    ST st = group.getInstanceOf("/subdir/a");
    st.add("x", new String[] {"a", "b"});
    assertEquals("ab", st.render());
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupDir

    writeFile(dir, "a.st", "a(x) ::= <<foo>>");
        String groupFile =
            "b() ::= \"bar\"\n"+
            "c() ::= \"duh\"\n";
        writeFile(dir, "group.stg", groupFile);
        STGroup group = new STGroupDir(dir);
    assertEquals("foo", group.getInstanceOf("a").render());
    assertEquals("bar", group.getInstanceOf("/group/b").render());
    assertEquals("duh", group.getInstanceOf("/group/c").render());
    }
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.