Skip to content

Commit 5d4cfdb

Browse files
committed
Add red test reproducing #4812
1 parent ccf525f commit 5d4cfdb

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed

RubberduckTests/Inspections/AssignmentNotUsedInspectionTests.cs

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
namespace RubberduckTests.Inspections
1111
{
1212
[TestFixture]
13+
[Category("Inspections")]
14+
[Category("AssignmentNotUsed")]
1315
public class AssignmentNotUsedInspectionTests
1416
{
1517
private IEnumerable<IInspectionResult> GetInspectionResults(string code, bool includeLibraries = false)
@@ -25,7 +27,6 @@ private IEnumerable<IInspectionResult> GetInspectionResults(string code, bool in
2527
}
2628

2729
[Test]
28-
[Category("Inspections")]
2930
public void IgnoresExplicitArrays()
3031
{
3132
const string code = @"
@@ -39,7 +40,6 @@ End Sub
3940
}
4041

4142
[Test]
42-
[Category("Inspections")]
4343
public void IgnoresImplicitArrays()
4444
{
4545
const string code = @"
@@ -54,7 +54,6 @@ End Sub
5454
}
5555

5656
[Test]
57-
[Category("Inspections")]
5857
public void IgnoresImplicitReDimmedArray()
5958
{
6059
const string code = @"
@@ -69,7 +68,6 @@ End Sub
6968
}
7069

7170
[Test]
72-
[Category("Inspections")]
7371
public void MarksSequentialAssignments()
7472
{
7573
const string code = @"
@@ -87,7 +85,6 @@ Sub Bar(ByVal i As Integer)
8785
}
8886

8987
[Test]
90-
[Category("Inspections")]
9188
public void MarksLastAssignmentInDeclarationBlock()
9289
{
9390
const string code = @"
@@ -100,7 +97,6 @@ Dim i As Integer
10097
}
10198

10299
[Test]
103-
[Category("Inspections")]
104100
// Note: both assignments in the if/else can be marked in the future;
105101
// I just want feedback before I start mucking around that deep.
106102
public void DoesNotMarkLastAssignmentInNonDeclarationBlock()
@@ -120,7 +116,6 @@ End If
120116
}
121117

122118
[Test]
123-
[Category("Inspections")]
124119
public void DoesNotMarkAssignmentWithReferenceAfter()
125120
{
126121
const string code = @"
@@ -137,7 +132,6 @@ Sub Bar(ByVal i As Integer)
137132
}
138133

139134
[Test]
140-
[Category("Inspections")]
141135
public void DoesNotMarkAssignment_UsedInForNext()
142136
{
143137
const string code = @"
@@ -152,7 +146,6 @@ Dim i As Integer
152146
}
153147

154148
[Test]
155-
[Category("Inspections")]
156149
public void DoesNotMarkAssignment_UsedInWhileWend()
157150
{
158151
const string code = @"
@@ -169,7 +162,6 @@ While i < 10
169162
}
170163

171164
[Test]
172-
[Category("Inspections")]
173165
public void DoesNotMarkAssignment_UsedInDoWhile()
174166
{
175167
const string code = @"
@@ -184,7 +176,6 @@ Do While i < 10
184176
}
185177

186178
[Test]
187-
[Category("Inspections")]
188179
public void DoesNotMarkAssignment_UsedInSelectCase()
189180
{
190181
const string code = @"
@@ -207,7 +198,6 @@ End Select
207198
}
208199

209200
[Test]
210-
[Category("Inspections")]
211201
public void DoesNotMarkAssignment_UsingNothing()
212202
{
213203
const string code = @"
@@ -224,7 +214,6 @@ Debug.Print my_fso.GetFolder(""C:\Windows"").DateLastModified
224214
}
225215

226216
[Test]
227-
[Category("Inspections")]
228217
public void DoesMarkAssignment_UsingNothing_NotUsed()
229218
{
230219
const string code = @"
@@ -237,5 +226,43 @@ Dim my_fso As Scripting.FileSystemObject
237226
var results = GetInspectionResults(code, includeLibraries: true);
238227
Assert.AreEqual(1, results.Count());
239228
}
229+
230+
[Test]
231+
public void DoesNotMarkResults_InIgnoredModule()
232+
{
233+
const string code = @"'@IgnoreModule
234+
Public Sub Test()
235+
Dim foo As Long
236+
foo = 1245316
237+
End Sub";
238+
var results = GetInspectionResults(code, includeLibraries: false);
239+
Assert.AreEqual(0, results.Count());
240+
}
241+
242+
[Test]
243+
public void DoesNotMarkAssignment_WithIgnoreOnceAnnotation()
244+
{
245+
const string code = @"Public Sub Test()
246+
Dim foo As Long
247+
'@Ignore AssignmentNotUsed
248+
foo = 123451
249+
foo = 56126
250+
End Sub";
251+
var results = GetInspectionResults(code, includeLibraries: false);
252+
Assert.AreEqual(1, results.Count());
253+
}
254+
255+
[Test]
256+
public void DoesNotMarkAssignment_ToIgnoredDeclaration()
257+
{
258+
const string code = @"Public Sub Test()
259+
'@Ignore AssignmentNotUsed
260+
Dim foo As Long
261+
foo = 123467
262+
foo = 45678
263+
End Sub";
264+
var results = GetInspectionResults(code, includeLibraries: false);
265+
Assert.AreEqual(0, results.Count());
266+
}
240267
}
241268
}

0 commit comments

Comments
 (0)