Merge pull request #40 from JohnSundell/xctassert
Add special case for `XCTAssert` family of functions
This commit is contained in:
commit
9a01bb7b85
@ -256,6 +256,13 @@ private extension SwiftGrammar {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The XCTAssert family of functions is a bit of an edge case,
|
||||||
|
// since they start with capital letters. Since they are so
|
||||||
|
// commonly used, we'll add a special case for them here:
|
||||||
|
guard !segment.tokens.current.starts(with: "XCTAssert") else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// In a generic declaration, only highlight constraints
|
// In a generic declaration, only highlight constraints
|
||||||
if segment.tokens.previous.isAny(of: "<", ",") {
|
if segment.tokens.previous.isAny(of: "<", ",") {
|
||||||
var foundOpeningBracket = false
|
var foundOpeningBracket = false
|
||||||
|
@ -130,6 +130,15 @@ final class FunctionCallTests: SyntaxHighlighterTestCase {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testXCTAssertCalls() {
|
||||||
|
let components = highlighter.highlight("XCTAssertTrue(variable)")
|
||||||
|
|
||||||
|
XCTAssertEqual(components, [
|
||||||
|
.token("XCTAssertTrue", .call),
|
||||||
|
.plainText("(variable)")
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
func testAllTestsRunOnLinux() {
|
func testAllTestsRunOnLinux() {
|
||||||
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
|
XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests))
|
||||||
}
|
}
|
||||||
@ -146,7 +155,8 @@ extension FunctionCallTests {
|
|||||||
("testAccessingPropertyAfterFunctionCallWithArguments", testAccessingPropertyAfterFunctionCallWithArguments),
|
("testAccessingPropertyAfterFunctionCallWithArguments", testAccessingPropertyAfterFunctionCallWithArguments),
|
||||||
("testCallingStaticMethodOnGenericType", testCallingStaticMethodOnGenericType),
|
("testCallingStaticMethodOnGenericType", testCallingStaticMethodOnGenericType),
|
||||||
("testPassingTypeToFunction", testPassingTypeToFunction),
|
("testPassingTypeToFunction", testPassingTypeToFunction),
|
||||||
("testPassingBoolToUnnamedArgument", testPassingBoolToUnnamedArgument)
|
("testPassingBoolToUnnamedArgument", testPassingBoolToUnnamedArgument),
|
||||||
|
("testXCTAssertCalls", testXCTAssertCalls)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user