diff --git a/Sources/Splash/Grammar/SwiftGrammar.swift b/Sources/Splash/Grammar/SwiftGrammar.swift index b6110ef..2c34db6 100644 --- a/Sources/Splash/Grammar/SwiftGrammar.swift +++ b/Sources/Splash/Grammar/SwiftGrammar.swift @@ -47,7 +47,7 @@ private extension SwiftGrammar { "super", "self", "set", "true", "false", "nil", "override", "where", "_", "default", "break", "#selector", "required", "willSet", "didSet", - "lazy", "subscript", "defer" + "lazy", "subscript", "defer", "inout" ] struct PreprocessingRule: SyntaxRule { diff --git a/Tests/SplashTests/Tests/DeclarationTests.swift b/Tests/SplashTests/Tests/DeclarationTests.swift index bf1c646..a7bdbf9 100644 --- a/Tests/SplashTests/Tests/DeclarationTests.swift +++ b/Tests/SplashTests/Tests/DeclarationTests.swift @@ -493,6 +493,32 @@ final class DeclarationTests: SyntaxHighlighterTestCase { .plainText("}") ]) } + + func testFunctionDeclarationWithInOutParameter() { + let components = highlighter.highlight("func swapValues(value1: inout Int, value2: inout Int) { }") + + XCTAssertEqual(components, [ + .token("func", .keyword), + .whitespace(" "), + .plainText("swapValues(value1:"), + .whitespace(" "), + .token("inout", .keyword), + .whitespace(" "), + .token("Int", .type), + .plainText(","), + .whitespace(" "), + .plainText("value2:"), + .whitespace(" "), + .token("inout", .keyword), + .whitespace(" "), + .token("Int", .type), + .plainText(")"), + .whitespace(" "), + .plainText("{"), + .whitespace(" "), + .plainText("}") + ]) + } func testAllTestsRunOnLinux() { XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests)) @@ -522,7 +548,8 @@ extension DeclarationTests { ("testPropertyDeclarationWithWillSet", testPropertyDeclarationWithWillSet), ("testPropertyDeclarationWithDidSet", testPropertyDeclarationWithDidSet), ("testSubscriptDeclaration", testSubscriptDeclaration), - ("testDeferDeclaration", testDeferDeclaration) + ("testDeferDeclaration", testDeferDeclaration), + ("testFunctionDeclarationWithInOutParameter", testFunctionDeclarationWithInOutParameter) ] } }