Merge pull request #3262 from lindenlab/add_continuations_test
[mono.git] / mcs / class / Mono.CSharp / Test / Visit / ASTVisitorTest.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using NUnit.Framework;
6 using Mono.CSharp;
7 using System.IO;
8
9 namespace MonoTests.Visit
10 {
11         [TestFixture]
12         public class ASTVisitorTest
13         {
14                 class TestVisitor : StructuralVisitor
15                 {
16                 }
17
18                 [SetUp]
19                 public void Setup ()
20                 {
21                 }
22
23                 [Test]
24                 public void Simple ()
25                 {
26                         //string content = @"class A { }";
27                         string content = @"
28
29 class Foo
30 {
31         void Bar ()
32         {
33 completionList.Add (""delegate"" + sb, ""md-keyword"", GettextCatalog.GetString (""Creates anonymous delegate.""), ""delegate"" + sb + "" {"" + Document.Editor.EolMarker + stateTracker.Engine.ThisLineIndent + TextEditorProperties.IndentString + ""|"" + Document.Editor.EolMarker + stateTracker.Engine.ThisLineIndent +""};"");
34         }
35 }"
36         ;
37
38
39                         var stream = new MemoryStream (Encoding.UTF8.GetBytes (content));
40
41                         var ctx = new CompilerContext (new CompilerSettings (), new AssertReportPrinter ());
42
43                         ModuleContainer module = new ModuleContainer (ctx);
44                         var file = new SourceFile ("test", "asdfas", 0);
45                         CSharpParser parser = new CSharpParser (
46                                 new SeekableStreamReader (stream, Encoding.UTF8),
47                                 new CompilationSourceFile (module, file),
48                                 ctx.Report,
49                                 new ParserSession ());
50
51                         RootContext.ToplevelTypes = module;
52                         Location.Initialize (new List<SourceFile> { file });
53                         parser.parse ();
54
55                         Assert.AreEqual (0, ctx.Report.Errors);
56
57                         module.Accept (new TestVisitor ());
58                 }
59         }
60 }