Added Mono.Tasklets 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 Report (new AssertReportPrinter ()));
42
43                         ModuleContainer module = new ModuleContainer (ctx);
44                         CSharpParser parser = new CSharpParser (
45                                 new SeekableStreamReader (stream, Encoding.UTF8),
46                                 new CompilationUnit ("name", "path", 0),
47                                 module);
48
49                         RootContext.ToplevelTypes = module;
50                         Location.AddFile (ctx.Report, "asdfas");
51                         Location.Initialize ();
52                         parser.LocationsBag = new LocationsBag ();
53                         parser.parse ();
54
55                         var m = module.Types[0].Methods[0] as Method;
56                         var s = m.Block.FirstStatement;
57                         var o = s.loc.Column;
58                         
59
60                         module.Accept (new TestVisitor ());
61                 }
62         }
63 }