Antlr4.Test.StringTemplate.TestVisualizer.TestBugArrayIndexOutOfBoundsExceptionInTemplateRuntimeMessage_SourceLocation C# (CSharp) Метод

TestBugArrayIndexOutOfBoundsExceptionInTemplateRuntimeMessage_SourceLocation() приватный Метод

        public void TestBugArrayIndexOutOfBoundsExceptionInTemplateRuntimeMessage_SourceLocation()
        {
            string templates = "main(doit = true) ::= "
                    + "\"<if(doit || other)><t(...)><endif>\"\n"
                    + "t2() ::= \"Hello\"\n" //
                    + "t(x={<(t2())>}) ::= \"<x>\"";

            writeFile(tmpdir, "t.stg", templates);

            TemplateGroup group = new TemplateGroupFile(Path.Combine(tmpdir, "t.stg"));

            Template st = group.GetInstanceOf("main");

            string s = st.Render();
            Assert.AreEqual("Hello", s);

            // Inspecting this template threw an ArrayIndexOutOfBoundsException in 4.0.2.
            // With the default for x changed to {<t2()>} (i.e. lazy eval) inspect
            // works fine. Also removing the " || other" and keeping the early eval
            // works fine with inspect.

            st.Visualize();
        }