Skip to content

Commit e81decf

Browse files
committed
Add unit tests for type hints
1 parent cae7967 commit e81decf

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

RubberduckTests/Inspections/ImplicitlyTypedConstInspectionTests.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,52 @@ public void ImplicitlyTypedConst_DoesNotReturnResult()
5353
Assert.AreEqual(expected, actual);
5454
}
5555

56+
[Test]
57+
[Category("Inspections")]
58+
[TestCase("!")]
59+
[TestCase("@")]
60+
[TestCase("#")]
61+
[TestCase("$")]
62+
[TestCase("%")]
63+
[TestCase("^")]
64+
[TestCase("&")]
65+
public void ImplicitlyTypedConst_HasTypeHint_DoesNotReturnResult(string typeHint)
66+
{
67+
string inputCode =
68+
$@"Public Sub Foo()
69+
Const bar{typeHint} = 0
70+
End Sub";
71+
72+
const int expected = 0;
73+
74+
var results = InspectionResultsForModules(("FooClass", inputCode, ComponentType.ClassModule));
75+
var actual = results.Count();
76+
Assert.AreEqual(expected, actual);
77+
}
78+
79+
[Test]
80+
[Category("Inspections")]
81+
[TestCase("!")]
82+
[TestCase("@")]
83+
[TestCase("#")]
84+
//[TestCase("$")] Errors out
85+
[TestCase("%")]
86+
[TestCase("^")]
87+
[TestCase("&")]
88+
public void ImplicitlyTypedConst_AssignedValueHasTypeHint_ReturnsResult(string typeHint)
89+
{
90+
string inputCode =
91+
$@"Public Sub Foo()
92+
Const bar = 0{typeHint}
93+
End Sub";
94+
95+
const int expected = 1;
96+
97+
var results = InspectionResultsForModules(("FooClass", inputCode, ComponentType.ClassModule));
98+
var actual = results.Count();
99+
Assert.AreEqual(expected, actual);
100+
}
101+
56102
[Test]
57103
[Category("Inspections")]
58104
public void ImplicitlyTypedConst_Ignored_DoesNotReturnResult()

0 commit comments

Comments
 (0)