mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 12:51:04 +01:00
Lex '''-delimited multiline string literals. (#2133)
"""-delimited literals are still lexed for error recovery but produce an error.
This commit is contained in:
@@ -56,7 +56,7 @@ TEST_F(LexerTest, HandlesEmptyBuffer) {
|
||||
}
|
||||
|
||||
TEST_F(LexerTest, TracksLinesAndColumns) {
|
||||
auto buffer = Lex("\n ;;\n ;;;\n x\"foo\" \"\"\"baz\n a\n \"\"\" y");
|
||||
auto buffer = Lex("\n ;;\n ;;;\n x\"foo\" '''baz\n a\n ''' y");
|
||||
EXPECT_FALSE(buffer.has_errors());
|
||||
EXPECT_THAT(buffer,
|
||||
HasTokens(llvm::ArrayRef<ExpectedToken>{
|
||||
@@ -721,10 +721,10 @@ TEST_F(LexerTest, StringLiterals) {
|
||||
llvm::StringLiteral testcase = R"(
|
||||
"hello world\n"
|
||||
|
||||
"""foo
|
||||
'''foo
|
||||
test \
|
||||
\xAB
|
||||
""" trailing
|
||||
''' trailing
|
||||
|
||||
#"""#
|
||||
|
||||
@@ -770,7 +770,8 @@ TEST_F(LexerTest, StringLiterals) {
|
||||
.indent_column = 5,
|
||||
.string_contents = {"\\0\"foo\"\\1"}},
|
||||
|
||||
// """x""" is three string literals, not one.
|
||||
// """x""" is three string literals, not one invalid
|
||||
// attempt at a block string literal.
|
||||
{.kind = TokenKind::StringLiteral(),
|
||||
.line = 15,
|
||||
.column = 5,
|
||||
@@ -794,18 +795,18 @@ TEST_F(LexerTest, InvalidStringLiterals) {
|
||||
llvm::StringLiteral invalid[] = {
|
||||
// clang-format off
|
||||
R"(")",
|
||||
R"("""
|
||||
"")",
|
||||
R"('''
|
||||
'')",
|
||||
R"("\)",
|
||||
R"("\")",
|
||||
R"("\\)",
|
||||
R"("\\\")",
|
||||
R"(""")",
|
||||
R"("""
|
||||
R"(''')",
|
||||
R"('''
|
||||
)",
|
||||
R"("""\)",
|
||||
R"(#"""
|
||||
""")",
|
||||
R"('''\)",
|
||||
R"(#'''
|
||||
''')",
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user