Skip to content

Commit

Permalink
Add test verifying that custom string interpolation works (#54)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JohnSundell authored Mar 11, 2019
1 parent f1c56b3 commit 43f163b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Tests/SplashTests/Tests/LiteralTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
let components = highlighter.highlight("""
let string = \"\"\"
Expand Down Expand Up @@ -194,6 +218,7 @@ extension LiteralTests {
("testStringLiteralWithEscapedQuote", testStringLiteralWithEscapedQuote),
("testStringLiteralWithAttribute", testStringLiteralWithAttribute),
("testStringLiteralInterpolation", testStringLiteralInterpolation),
("testStringLiteralWithCustomIterpolation", testStringLiteralWithCustomIterpolation),
("testMultiLineStringLiteral", testMultiLineStringLiteral),
("testSingleLineRawStringLiteral", testSingleLineRawStringLiteral),
("testMultiLineRawStringLiteral", testMultiLineRawStringLiteral),
Expand Down

0 comments on commit 43f163b

Please sign in to comment.