Browse Source

add some more unit tests for VB indentation and add colon as statement terminator

4.2
Siegfried Pammer 13 years ago
parent
commit
fde27ea60a
  1. 4
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  2. 48
      src/AddIns/BackendBindings/VBNetBinding/Test/FormattingStrategy/IndentationTests.cs

4
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs

@ -833,10 +833,10 @@ namespace ICSharpCode.VBNetBinding @@ -833,10 +833,10 @@ namespace ICSharpCode.VBNetBinding
internal static bool IsBlockEnd(Token current, Token prev)
{
if (current.Kind == Tokens.Next)
return prev.Kind == Tokens.EOL;
return prev.Kind == Tokens.EOL || prev.Kind == Tokens.Colon;
if (current.Kind == Tokens.Loop)
return prev.Kind == Tokens.EOL;
return prev.Kind == Tokens.EOL || prev.Kind == Tokens.Colon;
if (blockTokens.Contains(current.Kind))
return prev.Kind == Tokens.End;

48
src/AddIns/BackendBindings/VBNetBinding/Test/FormattingStrategy/IndentationTests.cs

@ -524,6 +524,54 @@ End Module"; @@ -524,6 +524,54 @@ End Module";
RunFormatTest(code, expected);
}
[Test]
public void ForNextOneLine()
{
string expected = @"Module Core
Sub Main
Dim a = 1
For i = 0 To 10 : Console.WriteLine(i) : Next
Dim b = 2
End Sub
End Module";
string code = @"Module Core
Sub Main
Dim a = 1
For i = 0 To 10 : Console.WriteLine(i) : Next
Dim b = 2
End Sub
End Module";
RunFormatTest(code, expected);
}
[Test]
public void RandomNext()
{
string expected = @"Module Core
Public Function GetRandomNumber( _
Optional ByVal Low As Integer = 1, _
Optional ByVal High As Integer = 100) As Integer
' Returns a random number,
' between the optional Low and High parameters
Return objRandom.Next(Low, High + 1)
End Function
End Module";
string code = @"Module Core
Public Function GetRandomNumber( _
Optional ByVal Low As Integer = 1, _
Optional ByVal High As Integer = 100) As Integer
' Returns a random number,
' between the optional Low and High parameters
Return objRandom.Next(Low, High + 1)
End Function
End Module";
RunFormatTest(code, expected);
}
void RunFormatTest(string code, string expectedCode)
{
AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor());

Loading…
Cancel
Save