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


C# ErrorBuffer类代码示例

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


ErrorBuffer类属于命名空间,在下文中一共展示了ErrorBuffer类的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: 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


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