public virtual void testMultiLevelInheritance()
 {
     // must loop up two levels to find bold()
     StringTemplateGroup rootgroup = new StringTemplateGroup("root");
     StringTemplateGroup level1 = new StringTemplateGroup("level1");
     StringTemplateGroup level2 = new StringTemplateGroup("level2");
     rootgroup.defineTemplate("bold", "<b>$it$</b>");
     level1.setSuperGroup(rootgroup);
     level2.setSuperGroup(level1);
     StringTemplateErrorListener errors = new ErrorBuffer();
     rootgroup.setErrorListener(errors);
     level1.setErrorListener(errors);
     level2.setErrorListener(errors);
     StringTemplate duh = new StringTemplate(level2, "$name:bold()$");
     duh.setAttribute("name", "Terence");
     String expecting = "<b>Terence</b>";
     Assert.AreEqual(duh.ToString(), expecting);
 }
 public virtual void testLazyEvalOfSuperInApplySuperTemplateRef()
 {
     StringTemplateGroup group = new StringTemplateGroup("super");
     StringTemplateGroup subGroup = new StringTemplateGroup("sub");
     subGroup.setSuperGroup(group);
     group.defineTemplate("bold", "<b>$it$</b>");
     subGroup.defineTemplate("bold", "<strong>$it$</strong>");
     // this is the same as testApplySuperTemplateRef() test
     // 'cept notice that here the supergroup defines page
     // As long as you create the instance via the subgroup,
     // "super." will evaluate lazily (i.e., not statically
     // during template compilation) to the templates
     // getGroup().superGroup value.  If I create instance
     // of page in group not subGroup, however, I will get
     // an error as superGroup is null for group "group".
     group.defineTemplate("page", "$name:super.bold()$");
     StringTemplate st = subGroup.getInstanceOf("page");
     st.setAttribute("name", "Ter");
     String expecting = "<b>Ter</b>";
     Assert.AreEqual(st.ToString(), expecting);
 }
 public virtual void testApplySuperTemplateRef()
 {
     StringTemplateGroup group = new StringTemplateGroup("super");
     StringTemplateGroup subGroup = new StringTemplateGroup("sub");
     subGroup.setSuperGroup(group);
     group.defineTemplate("bold", "<b>$it$</b>");
     subGroup.defineTemplate("bold", "<strong>$it$</strong>");
     subGroup.defineTemplate("page", "$name:super.bold()$");
     StringTemplate st = subGroup.getInstanceOf("page");
     st.setAttribute("name", "Ter");
     String expecting = "<b>Ter</b>";
     Assert.AreEqual(st.ToString(), expecting);
 }
 public virtual void testTemplatePolymorphism()
 {
     StringTemplateGroup group = new StringTemplateGroup("super");
     StringTemplateGroup subGroup = new StringTemplateGroup("sub");
     subGroup.setSuperGroup(group);
     // bold is defined in both super and sub
     // if you create an instance of page via the subgroup,
     // then bold() should evaluate to the subgroup not the super
     // even though page is defined in the super.  Just like polymorphism.
     group.defineTemplate("bold", "<b>$it$</b>");
     group.defineTemplate("page", "$name:bold()$");
     subGroup.defineTemplate("bold", "<strong>$it$</strong>");
     StringTemplate st = subGroup.getInstanceOf("page");
     st.setAttribute("name", "Ter");
     String expecting = "<strong>Ter</strong>";
     Assert.AreEqual(st.ToString(), expecting);
 }
 public virtual void testSuperTemplateRef()
 {
     // you can refer to a template defined in a super group via super.t()
     StringTemplateGroup group = new StringTemplateGroup("super");
     StringTemplateGroup subGroup = new StringTemplateGroup("sub");
     subGroup.setSuperGroup(group);
     group.defineTemplate("page", "$font()$:text");
     group.defineTemplate("font", "Helvetica");
     subGroup.defineTemplate("font", "$super.font()$ and Times");
     StringTemplate st = subGroup.getInstanceOf("page");
     String expecting = "Helvetica and Times:text";
     Assert.AreEqual(st.ToString(), expecting);
 }
 public virtual void testSimpleInheritance()
 {
     // make a bold template in the super group that you can inherit from sub
     StringTemplateGroup supergroup = new StringTemplateGroup("super");
     StringTemplateGroup subgroup = new StringTemplateGroup("sub");
     StringTemplate bold = supergroup.defineTemplate("bold", "<b>$it$</b>");
     subgroup.setSuperGroup(supergroup);
     StringTemplateErrorListener errors = new ErrorBuffer();
     subgroup.setErrorListener(errors);
     supergroup.setErrorListener(errors);
     StringTemplate duh = new StringTemplate(subgroup, "$name:bold()$");
     duh.setAttribute("name", "Terence");
     String expecting = "<b>Terence</b>";
     Assert.AreEqual(duh.ToString(), expecting);
 }