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

TestDictViaEnclosingTemplates2() private method

private TestDictViaEnclosingTemplates2 ( ) : void
return void
        public void TestDictViaEnclosingTemplates2()
        {
            string templates =
                    "typeInit ::= [\"int\":\"0\", \"float\":\"0.0\"] " + newline +
                    "intermediate(stuff) ::= \"<stuff>\"" + newline +
                    "var(type,name) ::= \"<type> <name> = <typeInit.(type)>;\"" + newline
                    ;
            writeFile(tmpdir, "test.stg", templates);
            TemplateGroup group = new TemplateGroupFile(Path.Combine(tmpdir, "test.stg"));
            Template interm = group.GetInstanceOf("intermediate");
            Template var = group.GetInstanceOf("var");
            var.Add("type", "int");
            var.Add("name", "x");
            interm.Add("stuff", var);
            string expecting = "int x = 0;";
            string result = interm.Render();
            Assert.AreEqual(expecting, result);
        }