Skip to content

Commit 96dbeb7

Browse files
committed
add tests for issue 3, 4 and pull request 8
1 parent 651263e commit 96dbeb7

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

Tests/ACLibDeclarationDictCore/DeclarationDictTestCodemodule.cls

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,20 @@ End Sub
104104

105105
Private Static Sub MyStaticSub(Optional ByVal Reset As Boolean = False)
106106
Static Counter2 As Integer
107+
End Sub
108+
109+
Private Sub TestPullrequest8_LineLabels()
110+
111+
On Error GoTo ErrHandler
112+
113+
114+
ExitHere:
115+
Exit Sub
116+
117+
ErrHandler:
118+
119+
120+
107121
End Sub
108122

109123
'---------------------------

Tests/ACLibDeclarationDictCore/DeclarationDictTests.cls

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ Public Sub ImportCode_InsertCodeLine_CheckKeys(ByVal Code As String, ByVal Expec
6363

6464
End Sub
6565

66+
'AccUnit:Row("Dim Abc(1) As String", "Abc")
67+
'AccUnit:Row("Dim Abc(1 To 2) As String", "Abc")
68+
'AccUnit: Row("Dim Abc(1, 2) As String", "Abc")
69+
'AccUnit: Row("Dim Abc(1, 2, 3) As String", "Abc")
70+
'AccUnit:Row("ReDim Abc(x, y) As String", "Abc")
71+
'AccUnit:Row("ReDim Abc(x, y, z) As String", "Abc")
72+
Public Sub ImportCode_Issue4_MultiDimArrayDeclaration(ByVal Code As String, ByVal Expected As String)
73+
74+
Dim Actual As String
75+
76+
m_DeclDict.ImportCode Code
77+
Actual = Join(m_DeclDict.WordsDict.Keys, "|")
78+
79+
Assert.That Actual, Iz.EqualTo(Expected)
80+
81+
End Sub
82+
83+
6684
'AccUnit:Row("Private Function Func1() As String" & Environment.NewLine & Environment.NewLine & " Dim X as String, Y As Long", "Func1|X|Y")
6785
'AccUnit:Row(Environment.NewLine & " Private abc " & Environment.NewLine & " Public X as String, Y As Long", "abc|X|Y")
6886
'AccUnit:Row("Private Function Func1() As String ' _" & Environment.NewLine & " Dim X as String, Y As Long", "Func1")
@@ -78,6 +96,31 @@ Public Sub ImportCode_InsertCodeLines_CheckKeys(ByVal Code As String, ByVal Expe
7896

7997
End Sub
8098

99+
'AccUnit:Row("Dim SomeFuncVar As Integer ' the next line should not be ignored" & Environment.NewLine & "Dim AnotherFuncVar As String", "SomeFuncVar|AnotherFuncVar")
100+
Public Sub ImportCode_Issue3_RemovingCommentCorruptsLineEndings(ByVal Code As String, ByVal Expected As String)
101+
102+
Dim Actual As String
103+
104+
m_DeclDict.ImportCode Code
105+
Actual = Join(m_DeclDict.WordsDict.Keys, "|")
106+
107+
Assert.That Actual, Iz.EqualTo(Expected)
108+
109+
End Sub
110+
111+
'AccUnit:Row(Environment.NewLine & "ExitHere:" & Environment.NewLine & "Dim Abc As String", "ExitHere|Abc")
112+
'AccUnit:Row(Environment.NewLine & "ExitHere: Dim Abc As String", "ExitHere|Abc")
113+
Public Sub ImportCode_Pullrequest8_LineLabel(ByVal Code As String, ByVal Expected As String)
114+
115+
Dim Actual As String
116+
117+
m_DeclDict.ImportCode Code
118+
Actual = Join(m_DeclDict.WordsDict.Keys, "|")
119+
120+
Assert.That Actual, Iz.EqualTo(Expected)
121+
122+
End Sub
123+
81124
'AccUnit:Row("Private Declare PtrSafe Sub Sleep Lib ""kernel32"" (ByVal dwMilliseconds As LongPtr)", "Sleep|dwMilliseconds")
82125
'AccUnit:Row("Private Declare PtrSafe Function CopyMemory Lib ""kernel32"" Alias ""RtlMoveMemory""(ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long) As Long", "CopyMemory|Destination|Source|Length")
83126
Public Sub ImportCode_API_CheckKeys(ByVal Code As String, ByVal Expected As String)
@@ -164,7 +207,8 @@ Public Sub ImportClassCodeModule_CheckKeysExists()
164207
"PropertySet", "ObjRef", _
165208
"TestMe", _
166209
"VariableParams", "Args", _
167-
"MyStaticSub", "Reset", "Counter2")
210+
"MyStaticSub", "Reset", "Counter2", _
211+
"TestPullrequest8_LineLabels", "ExitHere", "ErrHandler")
168212

169213

170214
m_DeclDict.ImportVBComponent CurrentVbProject.VBComponents("DeclarationDictTestCodemodule")

0 commit comments

Comments
 (0)