Skip to content

Commit ee5654b

Browse files
committed
Add a few tests
1 parent 811a423 commit ee5654b

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

RubberduckTests/Grammar/VBAParserTests.cs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,19 @@ End Sub
223223
AssertTree(parseResult.Item1, parseResult.Item2, "//moduleOption");
224224
}
225225

226+
[TestMethod]
227+
public void TestModuleOption_Indented()
228+
{
229+
string code = @"
230+
Option Explicit
231+
232+
Sub DoSomething()
233+
End Sub
234+
";
235+
var parseResult = Parse(code);
236+
AssertTree(parseResult.Item1, parseResult.Item2, "//moduleOption");
237+
}
238+
226239
[TestMethod]
227240
public void TestModuleConfig()
228241
{
@@ -928,6 +941,37 @@ Debug.Print 42
928941
AssertTree(parseResult.Item1, parseResult.Item2, "//subStmt");
929942
}
930943

944+
[TestMethod]
945+
public void TestFunction_Indented()
946+
{
947+
string code = @"
948+
Private Function Foo() As Boolean
949+
Foo = True
950+
End Function";
951+
var parseResult = Parse(code);
952+
AssertTree(parseResult.Item1, parseResult.Item2, "//functionStmt");
953+
}
954+
955+
[TestMethod]
956+
public void TestSub_Indented()
957+
{
958+
string code = @"
959+
Private Sub Foo()
960+
End Sub";
961+
var parseResult = Parse(code);
962+
AssertTree(parseResult.Item1, parseResult.Item2, "//subStmt");
963+
}
964+
965+
[TestMethod]
966+
public void TestSub_InconsistentlyIndented()
967+
{
968+
string code = @"
969+
Private Sub Foo()
970+
End Sub";
971+
var parseResult = Parse(code);
972+
AssertTree(parseResult.Item1, parseResult.Item2, "//subStmt");
973+
}
974+
931975
[TestMethod]
932976
public void TestPtrSafeAsVariable()
933977
{
@@ -963,7 +1007,6 @@ private Tuple<VBAParser, ParserRuleContext> Parse(string code)
9631007
// If SLL fails we want to get notified ASAP so we can fix it, that's why we don't retry using LL.
9641008
parser.Interpreter.PredictionMode = PredictionMode.Sll;
9651009
var tree = parser.startRule();
966-
var k = tree.ToStringTree(parser);
9671010
return Tuple.Create<VBAParser, ParserRuleContext>(parser, tree);
9681011
}
9691012

0 commit comments

Comments
 (0)