Skip to content

Commit

Permalink
feat(test): ensure '>=>' is token-split correctly
Browse files Browse the repository at this point in the history
Splitting '>=>' into '>' and '=>' is a bit tricky, so ensure we test
this case directly.
  • Loading branch information
strager committed Jan 21, 2024
1 parent ac96b53 commit 961984c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/test-lex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,21 @@ TEST_F(Test_Lex, split_greater_from_bigger_token) {
l.skip();
EXPECT_EQ(l.peek().type, Token_Type::semicolon);
}

{
Padded_String input(u8">=>;"_sv);
Lexer l(&input, &Null_Diag_Reporter::instance);
EXPECT_EQ(l.peek().type, Token_Type::greater_equal);

l.skip_as_greater();
EXPECT_EQ(l.peek().type, Token_Type::equal_greater);
EXPECT_EQ(l.peek().begin, &input[1]);
EXPECT_EQ(l.peek().end, &input[3]);
EXPECT_EQ(l.end_of_previous_token(), &input[1]);
l.skip();

EXPECT_EQ(l.peek().type, Token_Type::semicolon);
}
}

TEST_F(Test_Lex, split_greater_from_bigger_token_has_no_leading_newline) {
Expand Down

0 comments on commit 961984c

Please sign in to comment.