Antlr4.Test.StringTemplate.TestImports.TestImportRelativeDir C# (CSharp) Method

TestImportRelativeDir() private method

private TestImportRelativeDir ( ) : void
return void
        public void TestImportRelativeDir()
        {
            /*
            dir
                g.stg has a() that imports subdir with relative path
                subdir
                    a.st
                    b.st
                    c.st
             */
            string dir = tmpdir;
            string gstr =
                "import \"subdir\"\n" + // finds subdir in dir
                "a() ::= <<dir1 a>>\n";
            writeFile(dir, "g.stg", gstr);

            string a = "a() ::= <<subdir a>>\n";
            string b = "b() ::= <<subdir b>>\n";
            string c = "c() ::= <<subdir b>>\n";
            writeFile(dir, Path.Combine("subdir", "a.st"), a);
            writeFile(dir, Path.Combine("subdir", "b.st"), b);
            writeFile(dir, Path.Combine("subdir", "c.st"), c);

            TemplateGroup group = new TemplateGroupFile(Path.Combine(dir, "g.stg"));
            Template st = group.GetInstanceOf("b"); // visible only if import worked
            string expected = "subdir b";
            string result = st?.Render();
            Assert.AreEqual(expected, result);
            st = group.GetInstanceOf("c");
            result = st?.Render();
            Assert.AreEqual(expected, result);
        }