예제 #1
0
        public void TestDefaultValueTemplateWithArg()
        {
            String templates =
                "t(a={x | 2*<x>}) ::= \"[<a>]\"" + newline;

            WriteFile(tmpdir, "t.stg", templates);
            STGroup group = new STGroupFile(Path.Combine(tmpdir, "t.stg"));
            String expected =
                "t(a={x | 2*<x>}) ::= <<" + newline +
                "[<a>]" + newline +
                ">>" + newline;
            String result = group.Show();
            Assert.AreEqual(expected, result);
        }
예제 #2
0
 public void TestListAsTemplateArgument()
 {
     String templates =
             "test(names,phones) ::= \"<foo([names,phones])>\"" + newline +
             "foo(items) ::= \"<items:{a | *<a>*}>\"" + newline
             ;
     WriteFile(tmpdir, "t.stg", templates);
     STGroup group = new STGroupFile(tmpdir + "/" + "t.stg");
     ST e = group.GetInstanceOf("test");
     e.Add("names", "Ter");
     e.Add("names", "Tom");
     e.Add("phones", "1");
     e.Add("phones", "2");
     String expecting = "*Ter**Tom**1**2*";
     String result = e.Render();
     Assert.AreEqual(expecting, result);
 }
예제 #3
0
        public void TestMultiTemplates()
        {
            String templates =
                "ta() ::= \"[<it>]\"" + newline +
                "duh() ::= <<hi there>>" + newline +
                "wow() ::= <<last>>" + newline;

            WriteFile(tmpdir, "t.stg", templates);
            STGroup group = new STGroupFile(Path.Combine(tmpdir, "t.stg"));
            String expected =
                "ta() ::= <<" + newline +
                "[<it>]" + newline +
                ">>" + newline +
                "duh() ::= <<" + newline +
                "hi there" + newline +
                ">>" + newline +
                "wow() ::= <<" + newline +
                "last" + newline +
                ">>" + newline;
            String result = group.Show();
            Assert.AreEqual(expected, result);
        }
예제 #4
0
        public void TestSimpleGroup()
        {
            String templates =
                "t() ::= <<foo>>" + newline;

            WriteFile(tmpdir, "t.stg", templates);
            STGroup group = new STGroupFile(Path.Combine(tmpdir, "t.stg"));
            String expected =
                "t() ::= <<" + newline +
                "foo" + newline +
                ">>" + newline;
            String result = group.Show();
            Assert.AreEqual(expected, result);
        }
예제 #5
0
        public void TestNestedTemplateInGroupFile()
        {
            String templates =
                "t(a) ::= \"<a:{x | <x:{<it>}>}>\"" + newline;

            WriteFile(tmpdir, "t.stg", templates);
            STGroup group = new STGroupFile(Path.Combine(tmpdir, "t.stg"));
            String expected =
                "t(a) ::= <<" + newline +
                "<a:{x | <x:{<it>}>}>" + newline +
                ">>" + newline;
            String result = group.Show();
            Assert.AreEqual(expected, result);
        }