This is an archive of the discontinued LLVM Phabricator instance.

[clang] Add test for FindNextToken in Lexer.
ClosedPublic

Authored by usaxena95 on Oct 7 2019, 3:35 AM.

Details

Summary

Currently Lexer::FindNextToken does not have any unittests associated with it.

  • This patch adds a test for this method.
  • This test acts as a documentation for how to use this.
  • This method is used at various places in clang-tidy, clang and clangd using a similar pattern as in the tests. Thus this will prevent those usages to break in the future.

Diff Detail

Event Timeline

usaxena95 created this revision.Oct 7 2019, 3:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2019, 3:35 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
usaxena95 updated this revision to Diff 223503.Oct 7 2019, 4:36 AM

Revert unintended formatting.

Could you add a rationale in the change description? E.g. something like we do not have any tests for findNextToken

clang/unittests/Lex/LexerTest.cpp
558

NIT: could be replaced with

EXPECT_THAT(GeneratedByNextToken, ElementsAre("abcd", "=", ....))

To avoid creating an extra variable.
But up to you, this version also looks ok.

usaxena95 edited the summary of this revision. (Show Details)Oct 7 2019, 5:00 AM
usaxena95 updated this revision to Diff 223524.Oct 7 2019, 5:29 AM
usaxena95 marked an inline comment as done.

Addressed comments and fixed build failure.

This revision is now accepted and ready to land.Oct 7 2019, 6:18 AM
This revision was automatically updated to reflect the committed changes.