Skip to content

Commit fe4f7a5

Browse files
committed
Test cases for false multiline delimiters
1 parent 1d2c426 commit fe4f7a5

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

test/Parse/raw_string.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,37 @@ _ = ##"""
6868
"""##
6969
// CHECK: "a raw string with \"\"\" in it"
7070

71+
_ = #"""#
72+
// CHECK: "\""
73+
74+
_ = #""""#
75+
// CHECK: "\"\""
76+
77+
_ = #"""""#
78+
// CHECK: "\"\"\""
79+
80+
_ = #""""""#
81+
// CHECK: "\"\"\"\""
82+
83+
_ = ##""" foo # "# "##
84+
// CHECK: "\"\" foo # \"# "
85+
86+
_ = ###""" "# "## "###
87+
// CHECK: "\"\" \"# \"## "
88+
89+
_ = ###"""##"###
90+
// CHECK: "\"\"##"
91+
92+
_ = "interpolating \(#"""false delimiter"#)"
93+
// CHECK: "interpolating "
94+
// CHECK: "\"\"false delimiter"
95+
96+
_ = """
97+
interpolating \(#"""false delimiters"""#)
98+
"""
99+
// CHECK: "interpolating "
100+
// CHECK: "\"\"false delimiters\"\""
101+
71102
let foo = "Interpolation"
72103
_ = #"\b\b \#(foo)\#(foo) Kappa"#
73104
// CHECK: "\\b\\b "

test/Parse/raw_string_errors.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ let _ = #"\##("invalid")"#
99
// expected-error@-1{{too many '#' characters in delimited escape}}
1010
// expected-error@-2{{invalid escape sequence in literal}}
1111

12+
let _ = ###"""invalid"######
13+
// expected-error@-1{{too many '#' characters in closing delimiter}}{{26-29=}}
14+
// expected-error@-2{{consecutive statements on a line must be separated by ';'}}
15+
// expected-error@-3{{expected expression}}
16+
1217
let _ = ####"invalid"###
1318
// expected-error@-1{{unterminated string literal}}
1419
@@ -17,8 +22,16 @@ let _ = ###"invalid"######
1722
// expected-error@-2{{consecutive statements on a line must be separated by ';'}}
1823
// expected-error@-3{{expected expression}}
1924

20-
let _ = ##"""##
25+
let _ = ##"""aa
2126
foobar
22-
##"""##
27+
aa"""##
2328
// expected-error@-3{{multi-line string literal content must begin on a new line}}{{14-14=\n}}
2429
// expected-error@-2{{multi-line string literal closing delimiter must begin on a new line}}{{5-5=\n}}
30+
31+
let _ = #""" foo "bar" #baz
32+
"""#
33+
// expected-error@-2{{multi-line string literal content must begin on a new line}}{{13-13=\n}}
34+
35+
let _ = ###""" "# "##
36+
"""###
37+
// expected-error@-2{{multi-line string literal content must begin on a new line}}{{15-15=\n}}

0 commit comments

Comments
 (0)