diff --git a/lexer/string_literal.h b/lexer/string_literal.h index 91b01ccd67de..feb509027fa5 100644 --- a/lexer/string_literal.h +++ b/lexer/string_literal.h @@ -54,5 +54,4 @@ class StringLiteralToken { bool multi_line; }; - } // namespace Carbon diff --git a/lexer/string_literal_test.cpp b/lexer/string_literal_test.cpp index 6291b407f4c5..7c6aa32b4804 100644 --- a/lexer/string_literal_test.cpp +++ b/lexer/string_literal_test.cpp @@ -84,9 +84,9 @@ TEST_F(StringLiteralTest, StringLiteralBounds) { R"(")", R"(""" "")", - R"("\)", + R"("\)", // R"("\")", - R"("\\)", + R"("\\)", // R"("\\\")", R"(""" )", @@ -184,18 +184,18 @@ TEST_F(StringLiteralTest, StringLiteralContents) { TEST_F(StringLiteralTest, StringLiteralBadIndent) { std::pair testcases[] = { - // Indent doesn't match the last line. - {"\"\"\"\n \tx\n \"\"\"", "x\n"}, - {"\"\"\"\n x\n \"\"\"", "x\n"}, - {"\"\"\"\n x\n\t\"\"\"", "x\n"}, - {"\"\"\"\n ok\n bad\n \"\"\"", "ok\nbad\n"}, - {"\"\"\"\n bad\n ok\n \"\"\"", "bad\nok\n"}, - {"\"\"\"\n escaped,\\\n bad\n \"\"\"", "escaped,bad\n"}, + // Indent doesn't match the last line. + {"\"\"\"\n \tx\n \"\"\"", "x\n"}, + {"\"\"\"\n x\n \"\"\"", "x\n"}, + {"\"\"\"\n x\n\t\"\"\"", "x\n"}, + {"\"\"\"\n ok\n bad\n \"\"\"", "ok\nbad\n"}, + {"\"\"\"\n bad\n ok\n \"\"\"", "bad\nok\n"}, + {"\"\"\"\n escaped,\\\n bad\n \"\"\"", "escaped,bad\n"}, - // Indent on last line is followed by text. - {"\"\"\"\n x\n x\"\"\"", "x\nx"}, - {"\"\"\"\n x\n x\"\"\"", " x\nx"}, - {"\"\"\"\n x\n x\"\"\"", "x\nx"}, + // Indent on last line is followed by text. + {"\"\"\"\n x\n x\"\"\"", "x\nx"}, + {"\"\"\"\n x\n x\"\"\"", " x\nx"}, + {"\"\"\"\n x\n x\"\"\"", "x\nx"}, }; for (auto [test, contents] : testcases) { @@ -207,43 +207,43 @@ TEST_F(StringLiteralTest, StringLiteralBadIndent) { TEST_F(StringLiteralTest, StringLiteralBadEscapeSequence) { llvm::StringLiteral testcases[] = { - R"("\a")", - R"("\b")", - R"("\e")", - R"("\f")", - R"("\v")", - R"("\?")", - R"("\1")", - R"("\9")", + R"("\a")", + R"("\b")", + R"("\e")", + R"("\f")", + R"("\v")", + R"("\?")", + R"("\1")", + R"("\9")", - // \0 can't be followed by a decimal digit. - R"("\01")", - R"("\09")", + // \0 can't be followed by a decimal digit. + R"("\01")", + R"("\09")", - // \x requires two (uppercase) hexadecimal digits. - R"("\x")", - R"("\x0")", - R"("\x0G")", - R"("\xab")", - R"("\x\n")", - R"("\x\"")", + // \x requires two (uppercase) hexadecimal digits. + R"("\x")", + R"("\x0")", + R"("\x0G")", + R"("\xab")", + R"("\x\n")", + R"("\x\"")", - // \u requires a braced list of one or more hexadecimal digits. - R"("\u")", - R"("\u?")", - R"("\u\"")", - R"("\u{")", - R"("\u{}")", - R"("\u{A")", - R"("\u{G}")", - R"("\u{0000012323127z}")", - R"("\u{-3}")", + // \u requires a braced list of one or more hexadecimal digits. + R"("\u")", + R"("\u?")", + R"("\u\"")", + R"("\u{")", + R"("\u{}")", + R"("\u{A")", + R"("\u{G}")", + R"("\u{0000012323127z}")", + R"("\u{-3}")", - // \u must specify a non-surrogate code point. - R"("\u{110000}")", - R"("\u{000000000000000000000000000000000110000}")", - R"("\u{D800}")", - R"("\u{DFFF}")", + // \u must specify a non-surrogate code point. + R"("\u{110000}")", + R"("\u{000000000000000000000000000000000110000}")", + R"("\u{D800}")", + R"("\u{DFFF}")", }; for (llvm::StringLiteral test : testcases) { diff --git a/lexer/tokenized_buffer_test.cpp b/lexer/tokenized_buffer_test.cpp index da09d9e37c19..244b711229fb 100644 --- a/lexer/tokenized_buffer_test.cpp +++ b/lexer/tokenized_buffer_test.cpp @@ -721,14 +721,14 @@ TEST_F(LexerTest, InvalidStringLiterals) { llvm::StringLiteral invalid[] = { R"(")", R"(""" - "")", - R"("\)", - R"("\")", - R"("\\)", - R"("\\\")", + "")", // + R"("\)", // + R"("\")", // + R"("\\)", // + R"("\\\")", // R"(""")", R"(""" - )", + )", // R"("""\)", R"(#""" """)",