当前位置: 首页>>代码示例>>C#>>正文


C# ErrorBuffer.ToString方法代码示例

本文整理汇总了C#中ErrorBuffer.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorBuffer.ToString方法的具体用法?C# ErrorBuffer.ToString怎么用?C# ErrorBuffer.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ErrorBuffer的用法示例。


在下文中一共展示了ErrorBuffer.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestIllegalOption

 public void TestIllegalOption()
 {
     ErrorBuffer errors = new ErrorBuffer();
     ErrorManager.ErrorListener = errors;
     STGroup group = new STGroup();
     group.DefineTemplate(new TemplateName("test"), "<name; bad=\"ugly\">");
     ST st = group.GetInstanceOf("test");
     st.Add("name", "Ter");
     String expected = "Ter";
     String result = st.Render();
     Assert.AreEqual(expected, result);
     expected = "1:7: no such option: bad" + newline;
     Assert.AreEqual(expected, errors.ToString());
 }
开发者ID:bszafko,项目名称:antlrcs,代码行数:14,代码来源:TestOptions.cs

示例2: TestCantDefineEmbeddedRegionAgain

        public void TestCantDefineEmbeddedRegionAgain()
        {
            string dir = GetRandomDir();
            string g = "a() ::= <<[<@r>foo<@end>]>>\n" +
                       "@a.r() ::= <<bar>>\n"; // error; dup
            WriteFile(dir, "g.stg", g);

            TemplateGroup group = new TemplateGroupFile(Path.Combine(dir, "g.stg"));
            ErrorBuffer errors = new ErrorBuffer();
            ErrorManager.ErrorListener = errors;
            group.Load();
            string expected = "2:3: region a.r is embedded and thus already implicitly defined" + newline;
            string result = errors.ToString();
            Assert.AreEqual(expected, result);
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:15,代码来源:TestRegions.cs

示例3: TestArg

        public void TestArg()
        {
            String templates =
                "foo(a,) ::= << >>\n";
            WriteFile(tmpdir, "t.stg", templates);

            STGroup group = null;
            var errors = new ErrorBuffer();
            group = new STGroupFile(Path.Combine(tmpdir, "t.stg"));
            ErrorManager.ErrorListener = errors;
            group.Load(); // force load
            String expected = "t.stg 1:6: missing ID at ')'" + newline;
            String result = errors.ToString();
            Assert.AreEqual(expected, result);
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:15,代码来源:TestGroupSyntaxErrors.cs

示例4: TestHiddenFieldNotError

        public void TestHiddenFieldNotError()
        {
            ErrorBuffer errors = new ErrorBuffer();
            ErrorManager.ErrorListener = errors;

            String templates =
                "t(u) ::= \"<u.name>\"" + newline;

            WriteFile(tmpdir, "t.stg", templates);
            STGroup group = new STGroupFile(Path.Combine(tmpdir, "t.stg"));
            ST st = group.GetInstanceOf("t");
            st.Add("u", new UserHiddenNameField("parrt"));
            st.Render();
            String expected = "";
            String result = errors.ToString();
            Assert.AreEqual(expected, result);
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:17,代码来源:TestInterptimeErrors.cs

示例5: TestMissingSuperTemplate

        public void TestMissingSuperTemplate()
        {
            ErrorBuffer errors = new ErrorBuffer();
            ErrorManager.ErrorListener = errors;

            String templates =
                "t() ::= \"<super.t()>\"" + newline;

            WriteFile(tmpdir, "t.stg", templates);
            STGroup group = new STGroupFile(Path.Combine(tmpdir, "t.stg"));
            String templates2 =
                "u() ::= \"blech\"" + newline;

            WriteFile(tmpdir, "t2.stg", templates2);
            STGroup group2 = new STGroupFile(Path.Combine(tmpdir, "t2.stg"));
            group.ImportTemplates(group2);
            ST st = group.GetInstanceOf("t");
            st.Render();
            String expected = "context [t] 1:1 no such template: super.t" + newline;
            String result = errors.ToString();
            Assert.AreEqual(expected, result);
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:22,代码来源:TestInterptimeErrors.cs

示例6: TestMap2

        public void TestMap2()
        {
            String templates =
                "d ::= [\"k\":]\n";
            WriteFile(tmpdir, "t.stg", templates);

            STGroup group = null;
            ErrorBuffer errors = new ErrorBuffer();
            group = new STGroupFile(tmpdir + "/" + "t.stg");
            ErrorManager.ErrorListener = errors;
            group.Load(); // force load
            String expected = "t.stg 1:11: missing value for key at ']'" + newline;
            String result = errors.ToString();
            Assert.AreEqual(expected, result);
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:15,代码来源:TestGroupSyntaxErrors.cs

示例7: TestUndefinedArgNoProblemInCompatibilityMode

        public void TestUndefinedArgNoProblemInCompatibilityMode()
        {
            ErrorBuffer errors = new ErrorBuffer();
            ErrorManager.ErrorListener = errors;
            ErrorManager.CompatibilityMode = true;

            try
            {
                string templates =
                    "t() ::= \"<u()>\"\n" +
                    "u() ::= \"<x>\"\n";

                WriteFile(tmpdir, "t.stg", templates);
                STGroup group = new STGroupFile(tmpdir + "/" + "t.stg");
                ST st = group.GetInstanceOf("t");
                st.Render();
                String expected = "";
                String result = errors.ToString();
                Assert.AreEqual(expected, result);
            }
            finally
            {
                ErrorManager.CompatibilityMode = false;
            }
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:25,代码来源:TestInterptimeErrors.cs

示例8: testGroupSatisfiesSingleInterface

        public virtual void testGroupSatisfiesSingleInterface()
        {
            // this also tests the group loader
            IStringTemplateErrorListener errors = new ErrorBuffer();
            StringTemplateGroup.RegisterGroupLoader(new CommonGroupLoader(errors, TEMPDIR));
            string groupIStr = ""
                + "interface testI;" + NL
                + "t();" + NL
                + "bold(item);" + NL
                + "optional duh(a,b,c);" + NL;
            WriteFile(TEMPDIR, "testI.sti", groupIStr);

            string templates = ""
                + "group testG implements testI;" + NL
                + "t() ::= <<foo>>" + NL
                + "bold(item) ::= <<foo>>" + NL
                + "duh(a,b,c) ::= <<foo>>" + NL;

            WriteFile(TEMPDIR, "testG.stg", templates);

            file1 = new StreamReader(Path.Combine(TEMPDIR, "testG.stg"));
            StringTemplateGroup group = new StringTemplateGroup(file1, errors);

            string expecting = ""; // should be no errors
            Assert.AreEqual(expecting, errors.ToString());
        }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:26,代码来源:TestStringTemplate.cs

示例9: testImplicitRegionRedefError

 public void testImplicitRegionRedefError()
 {
     // cannot define an implicitly-defined template more than once
     string templates = ""
         + "group test;" + NL
         + "a() ::= \"X<@r()>Y\"" + NL
         + "@a.r() ::= \"foo\"" + NL
         + "@a.r() ::= \"bar\"" + NL;
     IStringTemplateErrorListener errors = new ErrorBuffer();
     StringTemplateGroup group =
         new StringTemplateGroup(new StringReader(templates), errors);
     StringTemplate st = group.GetInstanceOf("a");
     st.ToString();
     string result = errors.ToString();
     string expecting = "group test line 4: redefinition of template region: @a.r";
     Assert.AreEqual(expecting, result);
 }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:17,代码来源:TestStringTemplate.cs

示例10: testParallelAttributeIterationWithMissingArgs

 public virtual void testParallelAttributeIterationWithMissingArgs()
 {
 IStringTemplateErrorListener errors = new ErrorBuffer();
 StringTemplate e = new StringTemplate("$names,phones,salaries:{[email protected]$p$}; separator=\", \"$");
 e.ErrorListener = errors;
 e = e.GetInstanceOf();
 e.SetAttribute("names", "Tom");
 e.SetAttribute("phones", "2");
 e.SetAttribute("salaries", "big");
 e.ToString(); // generate the error
 string errorExpecting = "missing arguments in anonymous template in context [anonymous]";
 Assert.AreEqual(errorExpecting, errors.ToString());
 }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:13,代码来源:TestStringTemplate.cs

示例11: testCannotFindInterfaceFile

        public virtual void testCannotFindInterfaceFile()
        {
            // this also tests the group loader
            IStringTemplateErrorListener errors = new ErrorBuffer();
            StringTemplateGroup.RegisterGroupLoader(new CommonGroupLoader(errors, TEMPDIR));

            string templates = ""
                + "group testG implements blort;" + NL
                + "t() ::= <<foo>>" + NL
                + "bold(item) ::= <<foo>>" + NL
                + "duh(a,b,c) ::= <<foo>>" + NL;

            WriteFile(TEMPDIR, "testG.stg", templates);

            file1 = new StreamReader(Path.Combine(TEMPDIR, "testG.stg"));
            StringTemplateGroup group = new StringTemplateGroup(file1, errors);

            string expecting = "no such interface file 'blort.sti'";
            Assert.AreEqual(expecting, errors.ToString());
        }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:20,代码来源:TestStringTemplate.cs

示例12: TestMissingEmbeddedTemplate

        public void TestMissingEmbeddedTemplate()
        {
            ErrorBuffer errors = new ErrorBuffer();
            ErrorManager.ErrorListener = errors;

            String templates =
                "t() ::= \"<foo()>\"" + newline;

            WriteFile(tmpdir, "t.stg", templates);
            STGroup group = new STGroupFile(Path.Combine(tmpdir, "t.stg"));
            ST st = group.GetInstanceOf("t");
            st.Render();
            String expected = "context [t] 1:0 no such template: foo" + newline;
            String result = errors.ToString();
            Assert.AreEqual(expected, result);
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:16,代码来源:TestInterptimeErrors.cs

示例13: testSingleExprTemplateArgumentError

 public virtual void testSingleExprTemplateArgumentError()
 {
 string templates = ""
     + "group test;" + NL
     + "test(name) ::= \"<bold(name)>\"" + NL
     + "bold(item,ick) ::= \"*<item>*\"" + NL;
 IStringTemplateErrorListener errors = new ErrorBuffer();
 StringTemplateGroup group = new StringTemplateGroup(new StringReader(templates), typeof(AngleBracketTemplateLexer), errors);
 StringTemplate e = group.GetInstanceOf("test");
 e.SetAttribute("name", "Ter");
 string result = e.ToString();
 string expecting = "template bold must have exactly one formal arg in template context [test <invoke bold arg context>]";
 Assert.AreEqual(expecting, errors.ToString());
 }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:14,代码来源:TestStringTemplate.cs

示例14: TestMap3

        public void TestMap3()
        {
            String templates =
                "d ::= [\"k\":{dfkj}}]\n"; // extra }
            WriteFile(tmpdir, "t.stg", templates);

            STGroup group = null;
            ErrorBuffer errors = new ErrorBuffer();
            group = new STGroupFile(tmpdir + "/" + "t.stg");
            ErrorManager.ErrorListener = errors;
            group.Load(); // force load
            String expected = "t.stg 1:17: invalid character '}'" + newline;
            String result = errors.ToString();
            Assert.AreEqual(expected, result);
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:15,代码来源:TestGroupSyntaxErrors.cs

示例15: TestMissingTemplate

        public void TestMissingTemplate()
        {
            String templates =
                "foo() ::= \n";
            WriteFile(tmpdir, "t.stg", templates);

            STGroup group = null;
            ITemplateErrorListener errors = new ErrorBuffer();
            group = new STGroupFile(Path.Combine(tmpdir, "t.stg"));
            ErrorManager.ErrorListener = errors;
            group.Load(); // force load
            String expected = "t.stg 2:0: missing template at '<EOF>'" + newline;
            String result = errors.ToString();
            Assert.AreEqual(expected, result);
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:15,代码来源:TestGroupSyntaxErrors.cs


注:本文中的ErrorBuffer.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。