• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ErrorBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ErrorBuffer的典型用法代码示例。如果您正苦于以下问题:C# ErrorBuffer类的具体用法?C# ErrorBuffer怎么用?C# ErrorBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ErrorBuffer类属于命名空间,在下文中一共展示了ErrorBuffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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


示例3: 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


示例4: TestHiddenPropertyNotError

        public void TestHiddenPropertyNotError()
        {
            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 UserHiddenName("parrt"));
            st.Render();
            String expected = "";
            String result = errors.ToString();
            Assert.AreEqual(expected, result);
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:17,代码来源:TestInterptimeErrors.cs


示例5: testComputedPropertyName

 public virtual void testComputedPropertyName()
 {
 StringTemplateGroup group = new StringTemplateGroup("test");
 IStringTemplateErrorListener errors = new ErrorBuffer();
 group.ErrorListener = errors;
 StringTemplate t = new StringTemplate(group, "variable property $propName$=$v.(propName)$");
 t.SetAttribute("v", new Decl("i", "int"));
 t.SetAttribute("propName", "type");
 string expecting = "variable property type=int";
 string result = t.ToString();
 Assert.AreEqual(errors.ToString(), "");
 Assert.AreEqual(expecting, result);
 }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:13,代码来源:TestStringTemplate.cs


示例6: TestStringTypeMismatch2

 public void TestStringTypeMismatch2()
 {
     ErrorBuffer errors = new ErrorBuffer();
     ErrorManager.ErrorListener = errors;
     ST e = new ST("<strlen(s)>");
     e.Add("s", 34);
     e.Render(); // generate the error
     String errorExpecting = "context [anonymous] 1:1 function strlen expects a string not System.Int32" + newline;
     Assert.AreEqual(errorExpecting, errors.ToString());
 }
开发者ID:bszafko,项目名称:antlrcs,代码行数:10,代码来源:TestInterptimeErrors.cs


示例7: testSimpleIndentOfAttributeList

 public virtual void testSimpleIndentOfAttributeList()
 {
 string templates = ""
     + "group test;" + NL
     + "list(names) ::= <<" + @"  $names; separator=""\n""$" + NL
     + ">>" + NL;
 IStringTemplateErrorListener errors = new ErrorBuffer();
 StringTemplateGroup group = new StringTemplateGroup(new StringReader(templates), typeof(DefaultTemplateLexer), errors);
 StringTemplate t = group.GetInstanceOf("list");
 t.SetAttribute("names", "Terence");
 t.SetAttribute("names", "Jim");
 t.SetAttribute("names", "Sriram");
 string expecting = ""
     + "  Terence" + NL
     + "  Jim" + NL
     + "  Sriram";
 Assert.AreEqual(expecting, t.ToString());
 }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:18,代码来源:TestStringTemplate.cs


示例8: testImplicitOverriddenRegionRedefError

        public void testImplicitOverriddenRegionRedefError()
        {
            string templates1 = ""
                + "group super;" + NL
                + "a() ::= \"X<@r()>Y\""
                + "@a.r() ::= \"foo\"" + NL;
            StringTemplateGroup group = new StringTemplateGroup(
                new StringReader(templates1));

            string templates2 = ""
                + "group sub;" + NL
                + "@a.r() ::= \"foo\"" + NL
                + "@a.r() ::= \"bar\"" + NL;
            IStringTemplateErrorListener errors = new ErrorBuffer();
            StringTemplateGroup subGroup = new StringTemplateGroup(
                new StringReader(templates2), errors, group);

            StringTemplate st = subGroup.GetInstanceOf("a");
            string result = errors.ToString();
            string expecting = "group sub line 3: redefinition of template region: @a.r";
            Assert.AreEqual(expecting, result);
        }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:22,代码来源:TestStringTemplate.cs


示例9: testGroupExtendsSuperGroup

        public virtual void testGroupExtendsSuperGroup()
        {
            // this also tests the group loader
            IStringTemplateErrorListener errors = new ErrorBuffer();
            StringTemplateGroup.RegisterGroupLoader(
                new CommonGroupLoader(errors, TEMPDIR)
                );
            string superGroup = ""
                + "group superG;" + NL
                + "bold(item) ::= <<*<item>*>>;\n" + NL;
            WriteFile(TEMPDIR, "superG.stg", superGroup);

            string templates = ""
                + "group testG : superG;" + NL
                + "main(x) ::= <<$bold(x)$>>" + NL;

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

            file1 = new StreamReader(Path.Combine(TEMPDIR, "testG.stg"));
            StringTemplateGroup group = new StringTemplateGroup(file1, typeof(DefaultTemplateLexer), errors);
            StringTemplate st = group.GetInstanceOf("main");
            st.SetAttribute("x", "foo");

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


示例10: 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


示例11: 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


示例12: testListOfEmbeddedTemplateSeesEnclosingAttributes

 public virtual void testListOfEmbeddedTemplateSeesEnclosingAttributes()
 {
 string templates = ""
     + "group test;" + NL
     + "output(cond,items) ::= <<page: $items$>>" + NL
     + "mybody() ::= <<$font()$stuff>>" + NL
     + "font() ::= <<$if(cond)$this$else$that$endif$>>";
 IStringTemplateErrorListener errors = new ErrorBuffer();
 StringTemplateGroup group = new StringTemplateGroup(new StringReader(templates), typeof(DefaultTemplateLexer), errors);
 StringTemplate outputST = group.GetInstanceOf("output");
 StringTemplate bodyST1 = group.GetInstanceOf("mybody");
 StringTemplate bodyST2 = group.GetInstanceOf("mybody");
 StringTemplate bodyST3 = group.GetInstanceOf("mybody");
 outputST.SetAttribute("items", bodyST1);
 outputST.SetAttribute("items", bodyST2);
 outputST.SetAttribute("items", bodyST3);
 string expecting = "page: thatstuffthatstuffthatstuff";
 Assert.AreEqual(expecting, outputST.ToString());
 }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:19,代码来源:TestStringTemplate.cs


示例13: testNestedIndent

 public virtual void testNestedIndent()
 {
 string templates = ""
     + "group test;" + NL
     + "method(name,stats) ::= <<" + "void $name$() {" + NL
     + "\t$stats; separator=\"\\n\"$" + NL
     + "}" + NL
     + ">>" + NL
     + "ifstat(expr,stats) ::= <<" + NL
     + "if ($expr$) {" + NL
     + "  $stats; separator=\"\\n\"$" + NL
     + "}" + ">>" + NL
     + "assign(lhs,expr) ::= <<$lhs$=$expr$;>>" + NL;
 IStringTemplateErrorListener errors = new ErrorBuffer();
 StringTemplateGroup group = new StringTemplateGroup(new StringReader(templates), typeof(DefaultTemplateLexer), errors);
 StringTemplate t = group.GetInstanceOf("method");
 t.SetAttribute("name", "foo");
 StringTemplate s1 = group.GetInstanceOf("assign");
 s1.SetAttribute("lhs", "x");
 s1.SetAttribute("expr", "0");
 StringTemplate s2 = group.GetInstanceOf("ifstat");
 s2.SetAttribute("expr", "x>0");
 StringTemplate s2a = group.GetInstanceOf("assign");
 s2a.SetAttribute("lhs", "y");
 s2a.SetAttribute("expr", "x+y");
 StringTemplate s2b = group.GetInstanceOf("assign");
 s2b.SetAttribute("lhs", "z");
 s2b.SetAttribute("expr", "4");
 s2.SetAttribute("stats", s2a);
 s2.SetAttribute("stats", s2b);
 t.SetAttribute("stats", s1);
 t.SetAttribute("stats", s2);
 string expecting = ""
     + "void foo() {" + NL
     + "\tx=0;" + NL
     + "\tif (x>0) {" + NL
     + "\t  y=x+y;" + NL
     + "\t  z=4;" + NL
     + "\t}" + NL
     + "}";
 Assert.AreEqual(expecting, t.ToString());
 }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:42,代码来源:TestStringTemplate.cs


示例14: testIndentOfMultipleBlankLines

 public virtual void testIndentOfMultipleBlankLines()
 {
 string templates = ""
     + "group test;" + NL
     + "list(names) ::= <<" + "  $names$" + NL
     + ">>" + NL;
 IStringTemplateErrorListener errors = new ErrorBuffer();
 StringTemplateGroup group = new StringTemplateGroup(new StringReader(templates), typeof(DefaultTemplateLexer), errors);
 StringTemplate t = group.GetInstanceOf("list");
 t.SetAttribute("names", "Terence\n\nis a maniac");
 string expecting = ""
     + "  Terence\n\n"
     + "  is a maniac";
 Assert.AreEqual(expecting, t.ToString());
 }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:15,代码来源:TestStringTemplate.cs


示例15: 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


示例16: 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


示例17: TestUndefinedArg

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

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

            WriteFile(tmpdir, "t.stg", templates);
            STGroup group = new STGroupFile(Path.Combine(tmpdir, "t.stg"));
            group.Debug = true;
            ST st = group.GetInstanceOf("t");
            st.Render();
            String expected = "context [t, u] 1:1 attribute x isn't defined" + newline;
            String result = errors.ToString();
            Assert.AreEqual(expected, result);
        }
开发者ID:bszafko,项目名称:antlrcs,代码行数:18,代码来源:TestInterptimeErrors.cs


示例18: 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


示例19: testParallelAttributeIterationWithMismatchArgListSizes

 public virtual void testParallelAttributeIterationWithMismatchArgListSizes()
 {
 IStringTemplateErrorListener errors = new ErrorBuffer();
 StringTemplate e = new StringTemplate("$names,phones,salaries:{n,p | [email protected]$p$}; separator=\", \"$");
 e.ErrorListener = errors;
 e = e.GetInstanceOf();
 e.SetAttribute("names", "Ter");
 e.SetAttribute("names", "Tom");
 e.SetAttribute("phones", "1");
 e.SetAttribute("phones", "2");
 e.SetAttribute("salaries", "big");
 string expecting = "[email protected], [email protected]";
 Assert.AreEqual(expecting, e.ToString());
 string errorExpecting = "number of arguments [n, p] mismatch between attribute list and anonymous template in context [anonymous]";
 Assert.AreEqual(errorExpecting, errors.ToString());
 }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:16,代码来源:TestStringTemplate.cs


示例20: testEmptyIteratedValueGetsSeparator

 public virtual void testEmptyIteratedValueGetsSeparator()
 {
 StringTemplateGroup group = new StringTemplateGroup("test");
 IStringTemplateErrorListener errors = new ErrorBuffer();
 group.ErrorListener = errors;
 StringTemplate t = new StringTemplate(group, "$names; separator=\",\"$");
 t.SetAttribute("names", "Terence");
 t.SetAttribute("names", "");
 t.SetAttribute("names", "");
 t.SetAttribute("names", "Tom");
 t.SetAttribute("names", "Frank");
 t.SetAttribute("names", "");
 // empty values get separator still
 string expecting = "Terence,,,Tom,Frank,";
 string result = t.ToString();
 Assert.AreEqual(expecting, result);
 }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:17,代码来源:TestStringTemplate.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ErrorCallback类代码示例发布时间:2022-05-24
下一篇:
C# Error类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap