Issue #2121: Support new block string literal syntax in explorer (#2399)

This commit is contained in:
Priyananda Shenoy
2023-01-04 15:53:47 -08:00
committed by GitHub
parent 4daaa4866f
commit c87d271c53
14 changed files with 111 additions and 101 deletions
+2 -2
View File
@@ -10,10 +10,10 @@
package ExplorerTest api;
fn Main() -> i32 {
var s: String = """
var s: String = '''
A "block" ""string"" literal
with indent.
""";
''';
if (s == "A \"block\" \"\"string\"\" literal\n with indent.\n") {
return 0;
} else {
@@ -10,11 +10,11 @@
package ExplorerTest api;
fn Main() -> i32 {
var s: String = """
var s: String = '''
A block string literal
\"""
""";
if (s == "A block string literal\n\"\"\"\n") {
\'''
''';
if (s == "A block string literal\n'''\n") {
return 0;
} else {
return 1;
+2 -2
View File
@@ -10,10 +10,10 @@
package ExplorerTest api;
fn Main() -> i32 {
var s: String = """filetype
var s: String = '''filetype
A "block" ""string"" literal
with file type indicator.
""";
''';
if (s == "A \"block\" \"\"string\"\" literal\n with file type indicator.\n") {
return 0;
} else {
@@ -9,10 +9,10 @@
package ExplorerTest api;
fn Main() -> i32 {
// CHECK:STDERR: SYNTAX ERROR: {{.*}}/explorer/testdata/string/fail_block_quotes_not_on_own_line.carbon:[[@LINE+1]]: Invalid block string: Should end with triple quotes: error: closing """
var s: String = """
error: closing """ is not on its own line.
""";
// CHECK:STDERR: SYNTAX ERROR: {{.*}}/explorer/testdata/string/fail_block_quotes_not_on_own_line.carbon:[[@LINE+1]]: Invalid block string: Should end with triple quotes: error: closing '''
var s: String = '''
error: closing ''' is not on its own line.
''';
return 0;
}
@@ -10,9 +10,9 @@ package ExplorerTest api;
fn Main() -> i32 {
// CHECK:STDERR: SYNTAX ERROR: {{.*}}/explorer/testdata/string/fail_raw_block_more_hash_tags_on_left.carbon:[[@LINE+1]]: Unexpected end of file
var s: String = ##"""
var s: String = ##'''
error: there are more #s on the left than the right.
"""#;
'''#;
return 0;
}
@@ -10,9 +10,9 @@ package ExplorerTest api;
fn Main() -> i32 {
// CHECK:STDERR: SYNTAX ERROR: {{.*}}/explorer/testdata/string/fail_raw_block_more_hash_tags_on_right.carbon:[[@LINE+1]]: invalid character '\x23' in source file.
var s: String = #"""
var s: String = #'''
error: there are more #s on the right than the left.
"""##;
'''##;
return 0;
}
@@ -9,10 +9,10 @@
package ExplorerTest api;
fn Main() -> i32 {
// CHECK:STDERR: SYNTAX ERROR: {{.*}}/explorer/testdata/string/fail_raw_block_quotes_not_on_own_line.carbon:[[@LINE+1]]: Invalid block string: Should end with triple quotes: error: closing """
var s: String = #"""
error: closing """# is not on its own line.
"""#;
// CHECK:STDERR: SYNTAX ERROR: {{.*}}/explorer/testdata/string/fail_raw_block_quotes_not_on_own_line.carbon:[[@LINE+1]]: Invalid block string: Should end with triple quotes: error: closing '''
var s: String = #'''
error: closing '''# is not on its own line.
'''#;
return 0;
}
+1 -1
View File
@@ -10,7 +10,7 @@ package ExplorerTest api;
fn CompareStr(s: String) -> i32 {
// CHECK:STDERR: SYNTAX ERROR: {{.*}}/explorer/testdata/string/fail_raw_block_single_line.carbon:[[@LINE+1]]: Invalid block string: Too few lines
if (s == #"""raw string literal starting with """#) {
if (s == #'''raw string literal starting with '''#) {
return 0;
}
return 1;
+2 -2
View File
@@ -10,10 +10,10 @@
package ExplorerTest api;
fn Main() -> i32 {
var s: String = #"""
var s: String = #'''
A "block" ""string"" literal
with indent.
"""#;
'''#;
if (s == #"A \#"block\#" \#"\#"string\#"\#" literal\#n with indent.\#n"#) {
return 0;
} else {
@@ -10,10 +10,10 @@
package ExplorerTest api;
fn Main() -> i32 {
var s: String = #"""
var s: String = #'''
A block string literal
\
"""#;
'''#;
if (s == "A block string literal\n\\\n") {
return 0;
} else {
@@ -10,11 +10,11 @@
package ExplorerTest api;
fn Main() -> i32 {
var s: String = #"""
var s: String = #'''
A block string literal
\#"""#
"""#;
if (s == "A block string literal\n\"\"\"#\n") {
\#'''#
'''#;
if (s == "A block string literal\n'''#\n") {
return 0;
} else {
return 1;