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",
|
"extension", "let", "var", "func", "typealias",
|
||||||
"init", "guard", "if", "else", "return", "get",
|
"init", "guard", "if", "else", "return", "get",
|
||||||
"throw", "throws", "for", "in", "open", "weak",
|
"throw", "throws", "for", "in", "open", "weak",
|
||||||
"import", "mutating", "associatedtype", "case",
|
"import", "mutating", "nonmutating", "associatedtype",
|
||||||
"switch", "static", "do", "try", "catch", "as",
|
"case", "switch", "static", "do", "try", "catch", "as",
|
||||||
"super", "self", "set", "true", "false", "nil",
|
"super", "self", "set", "true", "false", "nil",
|
||||||
"override", "where", "_", "default", "break",
|
"override", "where", "_", "default", "break",
|
||||||
"#selector", "required", "willSet", "didSet",
|
"#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() {
|
func testIndirectEnumDeclaration() {
|
||||||
let components = highlighter.highlight("""
|
let components = highlighter.highlight("""
|
||||||
indirect enum Content {
|
indirect enum Content {
|
||||||
@ -793,6 +821,7 @@ extension DeclarationTests {
|
|||||||
("testFunctionDeclarationWithNonEscapedKeywordAsName", testFunctionDeclarationWithNonEscapedKeywordAsName),
|
("testFunctionDeclarationWithNonEscapedKeywordAsName", testFunctionDeclarationWithNonEscapedKeywordAsName),
|
||||||
("testFunctionDeclarationWithEscapedKeywordAsName", testFunctionDeclarationWithEscapedKeywordAsName),
|
("testFunctionDeclarationWithEscapedKeywordAsName", testFunctionDeclarationWithEscapedKeywordAsName),
|
||||||
("testFunctionDeclarationWithPreProcessors", testFunctionDeclarationWithPreProcessors),
|
("testFunctionDeclarationWithPreProcessors", testFunctionDeclarationWithPreProcessors),
|
||||||
|
("testNonMutatingFunction", testNonMutatingFunction),
|
||||||
("testIndirectEnumDeclaration", testIndirectEnumDeclaration)
|
("testIndirectEnumDeclaration", testIndirectEnumDeclaration)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user