Add test verifying that custom string interpolation works (#54)
Swift 5 enables us to define custom ways to interpolate expressions into strings, and Splash already successfully highlights that syntax, but let’s add a test to make sure that continues to be the case.
This commit is contained in:
parent
f1c56b342d
commit
43f163bebc
@ -76,6 +76,30 @@ final class LiteralTests: SyntaxHighlighterTestCase {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testStringLiteralWithCustomIterpolation() {
|
||||||
|
let components = highlighter.highlight("""
|
||||||
|
"Hello \\(label: a, b) world \\(label: call())"
|
||||||
|
""")
|
||||||
|
|
||||||
|
XCTAssertEqual(components, [
|
||||||
|
.token("\"Hello", .string),
|
||||||
|
.whitespace(" "),
|
||||||
|
.plainText("\\(label:"),
|
||||||
|
.whitespace(" "),
|
||||||
|
.plainText("a,"),
|
||||||
|
.whitespace(" "),
|
||||||
|
.plainText("b)"),
|
||||||
|
.whitespace(" "),
|
||||||
|
.token("world", .string),
|
||||||
|
.whitespace(" "),
|
||||||
|
.plainText("\\(label:"),
|
||||||
|
.whitespace(" "),
|
||||||
|
.token("call", .call),
|
||||||
|
.plainText("())"),
|
||||||
|
.token("\"", .string)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
func testMultiLineStringLiteral() {
|
func testMultiLineStringLiteral() {
|
||||||
let components = highlighter.highlight("""
|
let components = highlighter.highlight("""
|
||||||
let string = \"\"\"
|
let string = \"\"\"
|
||||||
@ -194,6 +218,7 @@ extension LiteralTests {
|
|||||||
("testStringLiteralWithEscapedQuote", testStringLiteralWithEscapedQuote),
|
("testStringLiteralWithEscapedQuote", testStringLiteralWithEscapedQuote),
|
||||||
("testStringLiteralWithAttribute", testStringLiteralWithAttribute),
|
("testStringLiteralWithAttribute", testStringLiteralWithAttribute),
|
||||||
("testStringLiteralInterpolation", testStringLiteralInterpolation),
|
("testStringLiteralInterpolation", testStringLiteralInterpolation),
|
||||||
|
("testStringLiteralWithCustomIterpolation", testStringLiteralWithCustomIterpolation),
|
||||||
("testMultiLineStringLiteral", testMultiLineStringLiteral),
|
("testMultiLineStringLiteral", testMultiLineStringLiteral),
|
||||||
("testSingleLineRawStringLiteral", testSingleLineRawStringLiteral),
|
("testSingleLineRawStringLiteral", testSingleLineRawStringLiteral),
|
||||||
("testMultiLineRawStringLiteral", testMultiLineRawStringLiteral),
|
("testMultiLineRawStringLiteral", testMultiLineRawStringLiteral),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user