Skip to content

Commit

Permalink
Add test verifying property wrapper compatibility (#73)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JohnSundell authored Jun 18, 2019
1 parent 0b22fa3 commit c582abf
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion Tests/SplashTests/Tests/DeclarationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
}
Expand Down Expand Up @@ -960,7 +990,8 @@ extension DeclarationTests {
("testNonMutatingFunction", testNonMutatingFunction),
("testRethrowingFunctionDeclaration", testRethrowingFunctionDeclaration),
("testFunctionDeclarationWithOpaqueReturnType", testFunctionDeclarationWithOpaqueReturnType),
("testIndirectEnumDeclaration", testIndirectEnumDeclaration)
("testIndirectEnumDeclaration", testIndirectEnumDeclaration),
("testWrappedPropertyDeclarations", testWrappedPropertyDeclarations)
]
}
}

0 comments on commit c582abf

Please sign in to comment.