feat(lexer): Comments
This commit is contained in:
parent
dc9e43e9ba
commit
8429733200
3 changed files with 61 additions and 3 deletions
|
@ -167,4 +167,27 @@ class LexerScanTest {
|
|||
|
||||
assertEquals("string with space", tokens[0].value, "Expected 'string with space', got ${tokens[0].value}")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun scan_comments_returns_nothing() {
|
||||
val lexer = Lexer("% comment")
|
||||
val tokens = lexer.scan()
|
||||
|
||||
assertEquals(1, tokens.size)
|
||||
|
||||
assertEquals(TokenType.EOF, tokens[0].type, "Expected EOF token, got ${tokens[0].type}")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun scan_comment_and_sentence_returns_sentence() {
|
||||
val tokens = Lexer("""
|
||||
% comment
|
||||
sentence
|
||||
""".trimIndent()).scan()
|
||||
|
||||
assertEquals(2, tokens.size)
|
||||
|
||||
assertEquals(TokenType.ALPHANUMERIC, tokens[0].type, "Expected ALPHANUMERIC token, got ${tokens[0].type}")
|
||||
assertEquals("sentence", tokens[0].value, "Expected 'sentence', got ${tokens[0].value}")
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue