aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-30 21:13:34 +0200
committerhachem <im@hachem.wtf>2026-08-30 21:13:34 +0200
commit13704a1df5c15af7163cc7764b0aeebc81ad2bdd (patch)
tree4b9f10e1a686e8a4a87534d974d0bc3c64bd3d61 /tests
parent5d13b5dc014b2e81325c627ce36c44633655b2a4 (diff)
feat: add comment support
Diffstat (limited to 'tests')
-rw-r--r--tests/lexer_test.c12
1 files changed, 12 insertions, 0 deletions
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);
}