File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed
RubberduckTests/SmartIndenter Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -19,11 +19,11 @@ internal class AbsoluteCodeLine
19
19
private static readonly Regex ProcedureEndRegex = new Regex ( @"^End\s(Sub|Function|Property)" ) ;
20
20
private static readonly Regex TypeEnumStartRegex = new Regex ( @"^(Public\s|Private\s)?(Enum\s|Type\s)" ) ;
21
21
private static readonly Regex TypeEnumEndRegex = new Regex ( @"^End\s(Enum|Type)" ) ;
22
- private static readonly Regex InProcedureInRegex = new Regex ( @"^If\s.*\sThen|^ElseIf\s.+\sThen$ |^Else$|^Case\s|^With|^For\s|^Do$|^Do\s|^While$|^While\s|^Select Case" ) ;
23
- private static readonly Regex InProcedureOutRegex = new Regex ( @"^(Else)? If\s.*\sThen\s|^Else$|^Case\s|^End With|^Next\s|^Next$|^Loop$|^Loop\s|^Wend$|^End If$|^End Select" ) ;
22
+ private static readonly Regex InProcedureInRegex = new Regex ( @"^(Else)? If\s.*\sThen|^Else$|^Case\s|^With|^For\s|^Do$|^Do\s|^While$|^While\s|^Select Case" ) ;
23
+ private static readonly Regex InProcedureOutRegex = new Regex ( @"^If\s.*\sThen\s|^Else$|^ElseIf\s.*\sThen |^Case\s|^End With|^Next\s|^Next$|^Loop$|^Loop\s|^Wend$|^End If$|^End Select" ) ;
24
24
private static readonly Regex DeclarationRegex = new Regex ( @"^(Dim|Const|Static|Public|Private)\s.*\sAs\s" ) ;
25
25
private static readonly Regex PrecompilerInRegex = new Regex ( @"^#(Else)?If\s.+Then$|^#Else$" ) ;
26
- private static readonly Regex PrecompilerOutRegex = new Regex ( @"^#ElseIf\s.+Then$ |^#Else$|#End\sIf$" ) ;
26
+ private static readonly Regex PrecompilerOutRegex = new Regex ( @"^#ElseIf\s.+Then|^#Else$|#End\sIf$" ) ;
27
27
private static readonly Regex SingleLineIfRegex = new Regex ( @"^If\s.*\sThen\s.*$" ) ;
28
28
29
29
private readonly IIndenterSettings _settings ;
Original file line number Diff line number Diff line change @@ -48,6 +48,39 @@ public void SingleLineIfStatementWorks()
48
48
Assert . IsTrue ( expected . SequenceEqual ( actual ) ) ;
49
49
}
50
50
51
+ [ TestMethod ]
52
+ [ TestCategory ( "Indenter" ) ]
53
+ public void ElseIfStatementWorks ( )
54
+ {
55
+ var code = new [ ]
56
+ {
57
+ "Public Function Test() As Integer" ,
58
+ "If Foo = 1 Then" ,
59
+ "Bar = 3" ,
60
+ "ElseIf Foo = 3 Then" ,
61
+ "Bar = 1" ,
62
+ "End If" ,
63
+ "Test = Bar" ,
64
+ "End Function"
65
+ } ;
66
+
67
+ var expected = new [ ]
68
+ {
69
+ "Public Function Test() As Integer" ,
70
+ " If Foo = 1 Then" ,
71
+ " Bar = 3" ,
72
+ " ElseIf Foo = 3 Then" ,
73
+ " Bar = 1" ,
74
+ " End If" ,
75
+ " Test = Bar" ,
76
+ "End Function"
77
+ } ;
78
+
79
+ var indenter = new Indenter ( null , ( ) => IndenterSettingsTests . GetMockIndenterSettings ( ) ) ;
80
+ var actual = indenter . Indent ( code , string . Empty ) ;
81
+ Assert . IsTrue ( expected . SequenceEqual ( actual ) ) ;
82
+ }
83
+
51
84
[ TestMethod ]
52
85
[ TestCategory ( "Indenter" ) ]
53
86
public void SingleLineElseIfStatementWorks ( )
You can’t perform that action at this time.
0 commit comments