Skip to content

Commit

Permalink
Merge pull request #2272 from hzeller/feature-20241002-newline-lexer
Browse files Browse the repository at this point in the history
Add test to verify that various TK_NEWLINES are tokenized correctly.
  • Loading branch information
hzeller authored Oct 3, 2024
2 parents d6cb218 + 47a2cde commit 86fbbdd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions verilog/parser/verilog_lexer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ static std::initializer_list<LexerTestData> kCommentTests = {
{{TK_EOL_COMMENT, "//foo"}}, // missing \n, but treat as if it were there
};

static std::initializer_list<LexerTestData> kNewlineTests = {
{{TK_NEWLINE, "\n"}, {TK_NEWLINE, "\n"}},
{{TK_NEWLINE, "\r"}, {TK_NEWLINE, "\r"}},
{{TK_NEWLINE, "\r\n"}, {TK_NEWLINE, "\r\n"}},
{{TK_NEWLINE, "\r"}, {TK_NEWLINE, "\r\n"}, {TK_NEWLINE, "\n"}}, // mix
};

// treating attributes lists as C-style comments,
// except they are not returned as comment blocks.
static std::initializer_list<SimpleTestData> kAttributeTests = {
Expand Down Expand Up @@ -2288,6 +2295,7 @@ static std::initializer_list<LexerTestData> kLexicalErrorTests = {
};

TEST(VerilogLexerTest, LexicalErrors) { TestLexer(kLexicalErrorTests); }
TEST(VerilogLexerTest, NewlineTests) { TestLexer(kNewlineTests); }
TEST(VerilogLexerTest, Comments) { TestLexer(kCommentTests); }
TEST(VerilogLexerTest, Attributes) { TestLexer(kAttributeTests, TK_ATTRIBUTE); }
TEST(VerilogLexerTest, AttributesSequence) {
Expand Down

0 comments on commit 86fbbdd

Please sign in to comment.