From b742c3cfa307cb0d0550e9aca4e54311041f63ed Mon Sep 17 00:00:00 2001 From: Nikhil Muskur Date: Tue, 4 Sep 2018 16:30:42 +0530 Subject: [PATCH 1/4] added "inout" as keyword --- Sources/Splash/Grammar/SwiftGrammar.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { From ea71fd7191663b7c24fcc38cbe73844e7ff00fdb Mon Sep 17 00:00:00 2001 From: Nikhil Muskur Date: Wed, 5 Sep 2018 06:58:51 +0530 Subject: [PATCH 2/4] test added for the "inout" keyword --- .../SplashTests/Tests/DeclarationTests.swift | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Tests/SplashTests/Tests/DeclarationTests.swift b/Tests/SplashTests/Tests/DeclarationTests.swift index bf1c646..30a4fc8 100644 --- a/Tests/SplashTests/Tests/DeclarationTests.swift +++ b/Tests/SplashTests/Tests/DeclarationTests.swift @@ -493,6 +493,31 @@ 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), + .whitespace(" "), + .plainText("{"), + .whitespace(" "), + .plainText("}") + ]) + } func testAllTestsRunOnLinux() { XCTAssertTrue(TestCaseVerifier.verifyLinuxTests((type(of: self)).allTests)) From 70f49996fc66cc5803ad54e61163a2776ef0f745 Mon Sep 17 00:00:00 2001 From: Nikhil Muskur Date: Wed, 5 Sep 2018 07:06:01 +0530 Subject: [PATCH 3/4] added the test case in allTests array --- Tests/SplashTests/Tests/DeclarationTests.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/SplashTests/Tests/DeclarationTests.swift b/Tests/SplashTests/Tests/DeclarationTests.swift index 30a4fc8..3fe7452 100644 --- a/Tests/SplashTests/Tests/DeclarationTests.swift +++ b/Tests/SplashTests/Tests/DeclarationTests.swift @@ -547,7 +547,8 @@ extension DeclarationTests { ("testPropertyDeclarationWithWillSet", testPropertyDeclarationWithWillSet), ("testPropertyDeclarationWithDidSet", testPropertyDeclarationWithDidSet), ("testSubscriptDeclaration", testSubscriptDeclaration), - ("testDeferDeclaration", testDeferDeclaration) + ("testDeferDeclaration", testDeferDeclaration), + ("testFunctionDeclarationWithInOutParameter", testFunctionDeclarationWithInOutParameter) ] } } From 7a2f284e5d843f7805be3173c1771687fb5e1008 Mon Sep 17 00:00:00 2001 From: Luffy Date: Wed, 5 Sep 2018 07:20:35 +0530 Subject: [PATCH 4/4] missed a component in the test declaration --- Tests/SplashTests/Tests/DeclarationTests.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/SplashTests/Tests/DeclarationTests.swift b/Tests/SplashTests/Tests/DeclarationTests.swift index 3fe7452..a7bdbf9 100644 --- a/Tests/SplashTests/Tests/DeclarationTests.swift +++ b/Tests/SplashTests/Tests/DeclarationTests.swift @@ -512,6 +512,7 @@ final class DeclarationTests: SyntaxHighlighterTestCase { .token("inout", .keyword), .whitespace(" "), .token("Int", .type), + .plainText(")"), .whitespace(" "), .plainText("{"), .whitespace(" "),