Merge pull request #14 from hotogwc/fix_defer_bug

added “defer” as a keyword
This commit is contained in:
John Sundell 2018-08-28 13:20:44 +02:00 committed by GitHub
commit 90a927cb71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -47,7 +47,7 @@ private extension SwiftGrammar {
"super", "self", "set", "true", "false", "nil",
"override", "where", "_", "default", "break",
"#selector", "required", "willSet", "didSet",
"lazy", "subscript"
"lazy", "subscript", "defer"
]
struct PreprocessingRule: SyntaxRule {

View File

@ -475,6 +475,25 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
.plainText("}")
])
}
func testDeferDeclaration() {
let components = highlighter.highlight("func hello() { defer {} }")
XCTAssertEqual(components, [
.token("func", .keyword),
.whitespace(" "),
.plainText("hello()"),
.whitespace(" "),
.plainText("{"),
.whitespace(" "),
.token("defer", .keyword),
.whitespace(" "),
.plainText("{}"),
.whitespace(" "),
.plainText("}")
])
}
func testAllTestsRunOnLinux() {
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
@ -503,7 +522,8 @@ extension DeclarationTests {
("testGenericPropertyDeclaration", testGenericPropertyDeclaration),
("testPropertyDeclarationWithWillSet", testPropertyDeclarationWithWillSet),
("testPropertyDeclarationWithDidSet", testPropertyDeclarationWithDidSet),
("testSubscriptDeclaration", testSubscriptDeclaration)
("testSubscriptDeclaration", testSubscriptDeclaration),
("testDeferDeclaration", testDeferDeclaration)
]
}
}