From 882732784bd4fbc2b82bf2b49160c0495348ba05 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Wed, 24 Jan 2024 13:43:01 +0800 Subject: [PATCH] libnixf: sync tokens, add basic test --- libnixf/test/Parse/Parser.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libnixf/test/Parse/Parser.cpp b/libnixf/test/Parse/Parser.cpp index 419e21eac..714a13df4 100644 --- a/libnixf/test/Parse/Parser.cpp +++ b/libnixf/test/Parse/Parser.cpp @@ -573,7 +573,24 @@ rec { ASSERT_TRUE(AST); - // TODO!!! + ASSERT_EQ(Diags.size(), 1); + const auto &D = Diags[0]; + ASSERT_TRUE(D.range().begin().isAt(2, 2, 9)); + ASSERT_TRUE(D.range().end().isAt(3, 13, 26)); + ASSERT_EQ(D.kind(), Diagnostic::DK_UnexpectedText); + ASSERT_EQ(D.args().size(), 0); + + // Check the note. + ASSERT_EQ(D.notes().size(), 0); + + // Check fix-it hints. + ASSERT_EQ(D.fixes().size(), 1); + ASSERT_EQ(D.fixes()[0].edits().size(), 1); + ASSERT_EQ(D.fixes()[0].message(), "remove unexpected text"); + const auto &F = D.fixes()[0].edits()[0]; + ASSERT_TRUE(F.oldRange().begin().isAt(2, 2, 9)); + ASSERT_TRUE(F.oldRange().end().isAt(3, 13, 26)); + ASSERT_EQ(F.newText(), ""); } } // namespace