Add test verifying property wrapper compatibility (#73)

Splash was already capable of highlighting property wrappers, since
anything following an `@` symbol is treated as a keyword, but this
change adds a test that makes sure that it’ll keep working.
This commit is contained in:
John Sundell 2019-06-18 13:37:57 +02:00 committed by GitHub
parent 0b22fa3dcd
commit c582abf0a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -916,6 +916,36 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
]) ])
} }
func testWrappedPropertyDeclarations() {
let components = highlighter.highlight("""
struct User {
@Persisted(key: "name") var name: String
}
""")
XCTAssertEqual(components, [
.token("struct", .keyword),
.whitespace(" "),
.plainText("User"),
.whitespace(" "),
.plainText("{"),
.whitespace("\n "),
.token("@Persisted", .keyword),
.plainText("(key:"),
.whitespace(" "),
.token(#""name""#, .string),
.plainText(")"),
.whitespace(" "),
.token("var", .keyword),
.whitespace(" "),
.plainText("name:"),
.whitespace(" "),
.token("String", .type),
.whitespace("\n"),
.plainText("}")
])
}
func testAllTestsRunOnLinux() { func testAllTestsRunOnLinux() {
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests)) XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
} }
@ -960,7 +990,8 @@ extension DeclarationTests {
("testNonMutatingFunction", testNonMutatingFunction), ("testNonMutatingFunction", testNonMutatingFunction),
("testRethrowingFunctionDeclaration", testRethrowingFunctionDeclaration), ("testRethrowingFunctionDeclaration", testRethrowingFunctionDeclaration),
("testFunctionDeclarationWithOpaqueReturnType", testFunctionDeclarationWithOpaqueReturnType), ("testFunctionDeclarationWithOpaqueReturnType", testFunctionDeclarationWithOpaqueReturnType),
("testIndirectEnumDeclaration", testIndirectEnumDeclaration) ("testIndirectEnumDeclaration", testIndirectEnumDeclaration),
("testWrappedPropertyDeclarations", testWrappedPropertyDeclarations)
] ]
} }
} }