~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.VB.Tests/Output/SpecialOutputVisitorTest.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Collections.Generic;
 
6
using System.IO;
 
7
 
 
8
using ICSharpCode.NRefactory.VB.Ast;
 
9
using ICSharpCode.NRefactory.VB.Parser;
 
10
using ICSharpCode.NRefactory.VB.PrettyPrinter;
 
11
 
 
12
using NUnit.Framework;
 
13
 
 
14
namespace ICSharpCode.NRefactory.VB.Tests.PrettyPrinter
 
15
{
 
16
        [TestFixture]
 
17
        public class SpecialOutputVisitorTest
 
18
        {
 
19
                void TestProgram(string program)
 
20
                {
 
21
                        VBParser parser = ParserFactory.CreateParser(new StringReader(program));
 
22
                        parser.Parse();
 
23
                        Assert.AreEqual("", parser.Errors.ErrorOutput);
 
24
                        VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor();
 
25
                        outputVisitor.Options.IndentationChar = ' ';
 
26
                        outputVisitor.Options.TabSize = 2;
 
27
                        outputVisitor.Options.IndentSize = 2;
 
28
                        using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(),
 
29
                                                            outputVisitor)) {
 
30
                                outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
 
31
                        }
 
32
                        Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
 
33
                        Assert.AreEqual(program.Replace("\r", ""), outputVisitor.Text.TrimEnd().Replace("\r", ""));
 
34
                        parser.Dispose();
 
35
                }
 
36
                
 
37
                [Test]
 
38
                public void Enum()
 
39
                {
 
40
                        TestProgram("Enum Test\n" +
 
41
                                      "  ' a\n" +
 
42
                                      "  m1\n" +
 
43
                                      "  ' b\n" +
 
44
                                      "  m2\n" +
 
45
                                      "  ' c\n" +
 
46
                                      "End Enum\n" +
 
47
                                      "' d");
 
48
                }
 
49
                
 
50
                [Test]
 
51
                public void CommentsInsideMethod()
 
52
                {
 
53
                        TestProgram(@"Public Class Class1
 
54
  Private Function test(l As Integer, lvw As Integer) As Boolean
 
55
    ' Begin
 
56
    Dim i As Integer = 1
 
57
    Return False
 
58
    ' End of method
 
59
  End Function
 
60
End Class");
 
61
                }
 
62
                
 
63
                [Test]
 
64
                public void BlankLines()
 
65
                {
 
66
                        TestProgram("Imports System\n" +
 
67
                                      "\n" +
 
68
                                      "Imports System.IO");
 
69
                        TestProgram("Imports System\n" +
 
70
                                      "\n" +
 
71
                                      "\n" +
 
72
                                      "Imports System.IO");
 
73
                        TestProgram("\n" +
 
74
                                      "' Some comment\n" +
 
75
                                      "\n" +
 
76
                                      "Imports System.IO");
 
77
                }
 
78
        }
 
79
}