mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Reject invalid string literal whitespace on unescape (#793)
This is based on discussion on #732: that we should probably parse the invalid whitespace, then reject it as part of string validation, rather than having different parses. I worry the question of "how is this parsed" may lead to subtly unexpected results if we aren't consistent, so I'm switching the logic from the lexer to the unescape library (and also adjusting the list of rejected whitespace).
This commit is contained in:
@@ -17,6 +17,8 @@ namespace {
|
||||
|
||||
TEST(UnescapeStringLiteral, Valid) {
|
||||
EXPECT_THAT(UnescapeStringLiteral("test"), Optional(Eq("test")));
|
||||
EXPECT_THAT(UnescapeStringLiteral("okay whitespace"),
|
||||
Optional(Eq("okay whitespace")));
|
||||
EXPECT_THAT(UnescapeStringLiteral("test\n"), Optional(Eq("test\n")));
|
||||
EXPECT_THAT(UnescapeStringLiteral("test\\n"), Optional(Eq("test\n")));
|
||||
EXPECT_THAT(UnescapeStringLiteral("abc\\ndef"), Optional(Eq("abc\ndef")));
|
||||
|
||||
Reference in New Issue
Block a user