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