Adding nonmutating support (#50)
This commit is contained in:
parent
1a77051c67
commit
9a7fdefab4
@ -41,8 +41,8 @@ private extension SwiftGrammar {
|
||||
"extension", "let", "var", "func", "typealias",
|
||||
"init", "guard", "if", "else", "return", "get",
|
||||
"throw", "throws", "for", "in", "open", "weak",
|
||||
"import", "mutating", "associatedtype", "case",
|
||||
"switch", "static", "do", "try", "catch", "as",
|
||||
"import", "mutating", "nonmutating", "associatedtype",
|
||||
"case", "switch", "static", "do", "try", "catch", "as",
|
||||
"super", "self", "set", "true", "false", "nil",
|
||||
"override", "where", "_", "default", "break",
|
||||
"#selector", "required", "willSet", "didSet",
|
||||
|
@ -722,6 +722,34 @@ final class DeclarationTests: SyntaxHighlighterTestCase {
|
||||
])
|
||||
}
|
||||
|
||||
func testNonMutatingFunction() {
|
||||
let components = highlighter.highlight("""
|
||||
struct MyStruct {
|
||||
nonmutating func doNotChangeState() { }
|
||||
}
|
||||
""")
|
||||
|
||||
XCTAssertEqual(components, [
|
||||
.token("struct", .keyword),
|
||||
.whitespace(" "),
|
||||
.plainText("MyStruct"),
|
||||
.whitespace(" "),
|
||||
.plainText("{"),
|
||||
.whitespace("\n "),
|
||||
.token("nonmutating", .keyword),
|
||||
.whitespace(" "),
|
||||
.token("func", .keyword),
|
||||
.whitespace(" "),
|
||||
.plainText("doNotChangeState()"),
|
||||
.whitespace(" "),
|
||||
.plainText("{"),
|
||||
.whitespace(" "),
|
||||
.plainText("}"),
|
||||
.whitespace("\n"),
|
||||
.plainText("}")
|
||||
])
|
||||
}
|
||||
|
||||
func testIndirectEnumDeclaration() {
|
||||
let components = highlighter.highlight("""
|
||||
indirect enum Content {
|
||||
@ -793,6 +821,7 @@ extension DeclarationTests {
|
||||
("testFunctionDeclarationWithNonEscapedKeywordAsName", testFunctionDeclarationWithNonEscapedKeywordAsName),
|
||||
("testFunctionDeclarationWithEscapedKeywordAsName", testFunctionDeclarationWithEscapedKeywordAsName),
|
||||
("testFunctionDeclarationWithPreProcessors", testFunctionDeclarationWithPreProcessors),
|
||||
("testNonMutatingFunction", testNonMutatingFunction),
|
||||
("testIndirectEnumDeclaration", testIndirectEnumDeclaration)
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user