Merge pull request #33 from JohnSundell/indirect-enums

Add support for indirect enums
This commit is contained in:
John Sundell 2019-03-06 10:42:30 +01:00 committed by GitHub
commit a3f7fb43c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View File

@ -48,7 +48,7 @@ private extension SwiftGrammar {
"override", "where", "_", "default", "break",
"#selector", "required", "willSet", "didSet",
"lazy", "subscript", "defer", "inout", "while",
"continue", "fallthrough", "repeat"
"continue", "fallthrough", "repeat", "indirect"
]
struct PreprocessingRule: SyntaxRule {

View File

@ -520,6 +520,39 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
])
}
func testIndirectEnumDeclaration() {
let components = highlighter.highlight("""
indirect enum Content {
case single(String)
case collection([Content])
}
""")
XCTAssertEqual(components, [
.token("indirect", .keyword),
.whitespace(" "),
.token("enum", .keyword),
.whitespace(" "),
.plainText("Content"),
.whitespace(" "),
.plainText("{"),
.whitespace("\n "),
.token("case", .keyword),
.whitespace(" "),
.plainText("single("),
.token("String", .type),
.plainText(")"),
.whitespace("\n "),
.token("case", .keyword),
.whitespace(" "),
.plainText("collection(["),
.token("Content", .type),
.plainText("])"),
.whitespace("\n"),
.plainText("}")
])
}
func testAllTestsRunOnLinux() {
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
}
@ -549,7 +582,8 @@ extension DeclarationTests {
("testPropertyDeclarationWithDidSet", testPropertyDeclarationWithDidSet),
("testSubscriptDeclaration", testSubscriptDeclaration),
("testDeferDeclaration", testDeferDeclaration),
("testFunctionDeclarationWithInOutParameter", testFunctionDeclarationWithInOutParameter)
("testFunctionDeclarationWithInOutParameter", testFunctionDeclarationWithInOutParameter),
("testIndirectEnumDeclaration", testIndirectEnumDeclaration)
]
}
}