From 13704a1df5c15af7163cc7764b0aeebc81ad2bdd Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 30 Aug 2026 21:13:34 +0200 Subject: feat: add comment support --- tests/lexer_test.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/lexer_test.c') diff --git a/tests/lexer_test.c b/tests/lexer_test.c index c5c9f14..11b15b9 100644 --- a/tests/lexer_test.c +++ b/tests/lexer_test.c @@ -53,6 +53,17 @@ static void test_line_counting(struct TestContext* context) check(context, scan_token(&lexer).line == 3); } +static void test_comments(struct TestContext* context) +{ + struct Lexer lexer = create_lexer("rax // line comment\n/* block\ncomment */ rbx"); + check(context, token_matches(scan_token(&lexer), TOKEN_IDENTIFIER, "rax")); + + struct Token second = scan_token(&lexer); + check(context, token_matches(second, TOKEN_IDENTIFIER, "rbx")); + check(context, second.line == 3); + check(context, scan_token(&lexer).type == TOKEN_EOF); +} + void run_lexer_tests(struct TestContext* context) { test_identifiers_and_integers(context); @@ -60,4 +71,5 @@ void run_lexer_tests(struct TestContext* context) test_literals(context); test_keywords(context); test_line_counting(context); + test_comments(context); } -- cgit v1.3