-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from adriantodt/bugfix/unterminatedUnicodeLiteral
Bugfix: unterminated unicode literal
- Loading branch information
Showing
5 changed files
with
151 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
36 changes: 36 additions & 0 deletions
36
...commonTest/kotlin/com/github/adriantodt/lin/test/regression/lexer/LexerRegressionTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.github.adriantodt.lin.test.regression.lexer | ||
|
||
import com.github.adriantodt.lin.Lin | ||
import com.github.adriantodt.tartar.api.lexer.Source | ||
import com.github.adriantodt.tartar.api.parser.SyntaxException | ||
import kotlin.test.* | ||
|
||
class LexerRegressionTests { | ||
@Test | ||
fun unterminatedUnicodeLiteral() { | ||
val code = """ | ||
"\u123 | ||
""".trimIndent() | ||
val throwable = assertFails { | ||
Lin.parser.lexer.parseToList(Source(code, "unterminatedUnicodeLiteral.lin")) | ||
} | ||
assertIs<SyntaxException>(throwable) | ||
val section = throwable.section | ||
assertNotNull(section) | ||
assertEquals("\\u123", section.substring) | ||
} | ||
|
||
@Test | ||
fun unterminatedString() { | ||
val code = """ | ||
"ABC | ||
""".trimIndent() | ||
val throwable = assertFails { | ||
Lin.parser.lexer.parseToList(Source(code, "unterminatedString.lin")) | ||
} | ||
assertIs<SyntaxException>(throwable) | ||
val section = throwable.section | ||
assertNotNull(section) | ||
assertEquals("\"ABC", section.substring) | ||
} | ||
} |