Antlr4.Test.StringTemplate.TestDictionaries.TestTemplatesInDictionary C# (CSharp) Method

TestTemplatesInDictionary() private method

private TestTemplatesInDictionary ( ) : void
return void
        public void TestTemplatesInDictionary()
        {
            string templates =
                "auxMap ::= [\n" +
                "   \"E\": {electric <field>},\n" +
                "   \"I\": {in <field> between},\n" +
                "   \"F\": {<field> force},\n" +
                "   default: {<field>}\n" +
                "]\n" +
                "\n" +
                "makeTmpl(type, field) ::= <<\n" +
                "<auxMap.(type)>\n" +
                ">>\n" +
                "\n" +
                "top() ::= <<\n" +
                "  <makeTmpl(\"E\", \"foo\")>\n" +
                "  <makeTmpl(\"F\", \"foo\")>\n" +
                "  <makeTmpl(\"I\", \"foo\")>\n" +
                ">>\n";
            writeFile(tmpdir, "t.stg", templates);
            TemplateGroup group = new TemplateGroupFile(tmpdir + Path.DirectorySeparatorChar + "t.stg");
            Template st = group.GetInstanceOf("top");
            Assert.IsNotNull(st);
            string expecting =
                "  electric foo" + newline +
                "  foo force" + newline +
                "  in foo between";
            Assert.AreEqual(expecting, st.Render());
        }