Skip to content

Commit

Permalink
Run swift-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Matejkob authored and github-actions[bot] committed Dec 31, 2023
1 parent 43b9cfe commit 52acf5a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 59 deletions.
34 changes: 18 additions & 16 deletions Tests/SpyableMacroTests/Factories/UT_ReceivedArgumentsFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,47 +65,48 @@ final class UT_ReceivedArgumentsFactory: XCTestCase {

func testVariableDeclarationMultiArguments() throws {
try assertProtocolFunction(
withFunctionDeclaration: "func foo(text: String, _ count: (x: Int, UInt?)?, final price: Decimal?)",
withFunctionDeclaration:
"func foo(text: String, _ count: (x: Int, UInt?)?, final price: Decimal?)",
prefixForVariable: "_prefix_",
expectingVariableDeclaration: """
var _prefix_ReceivedArguments: (text: String, count: (x: Int, UInt?)?, price: Decimal?)?
"""
var _prefix_ReceivedArguments: (text: String, count: (x: Int, UInt?)?, price: Decimal?)?
"""
)
}

func testVariableDeclarationMultiArgumentsWithEscapingAttribute() throws {
try assertProtocolFunction(
withFunctionDeclaration: """
func foo(completion: @escaping () -> Void, _ count: (x: Int, UInt?)?, final price: Decimal?)
""",
func foo(completion: @escaping () -> Void, _ count: (x: Int, UInt?)?, final price: Decimal?)
""",
prefixForVariable: "_prefix_",
expectingVariableDeclaration: """
var _prefix_ReceivedArguments: (completion: () -> Void, count: (x: Int, UInt?)?, price: Decimal?)?
"""
var _prefix_ReceivedArguments: (completion: () -> Void, count: (x: Int, UInt?)?, price: Decimal?)?
"""
)
}

func testVariableDeclarationMultiArgumentsWithSomeClosureArgument() throws {
try assertProtocolFunction(
withFunctionDeclaration: """
func foo(completion: () -> Void, _ count: (x: Int, UInt?)?, final price: Decimal?)
""",
func foo(completion: () -> Void, _ count: (x: Int, UInt?)?, final price: Decimal?)
""",
prefixForVariable: "_prefix_",
expectingVariableDeclaration: """
var _prefix_ReceivedArguments: (completion: () -> Void, count: (x: Int, UInt?)?, price: Decimal?)?
"""
var _prefix_ReceivedArguments: (completion: () -> Void, count: (x: Int, UInt?)?, price: Decimal?)?
"""
)
}

func testVariableDeclarationMultiArgumentsWithSomeOptionalClosureArgument() throws {
try assertProtocolFunction(
withFunctionDeclaration: """
func foo(completion: (() -> Void)?, _ count: (x: Int, UInt?)?, final price: Decimal?)
""",
func foo(completion: (() -> Void)?, _ count: (x: Int, UInt?)?, final price: Decimal?)
""",
prefixForVariable: "_prefix_",
expectingVariableDeclaration: """
var _prefix_ReceivedArguments: (completion: (() -> Void)?, count: (x: Int, UInt?)?, price: Decimal?)?
"""
var _prefix_ReceivedArguments: (completion: (() -> Void)?, count: (x: Int, UInt?)?, price: Decimal?)?
"""
)
}

Expand Down Expand Up @@ -137,7 +138,8 @@ final class UT_ReceivedArgumentsFactory: XCTestCase {

func testAssignValueToVariableExpressionMultiArguments() throws {
try assertProtocolFunction(
withFunctionDeclaration: "func foo(text: String, _ count: (x: Int, UInt?)?, final price: Decimal?)",
withFunctionDeclaration:
"func foo(text: String, _ count: (x: Int, UInt?)?, final price: Decimal?)",
prefixForVariable: "_prefix_",
expectingExpression: "_prefix_ReceivedArguments = (text, count, price)"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ final class UT_ReceivedInvocationsFactory: XCTestCase {
withFunctionDeclaration: "func foo(_ tuple: (text: String, (Decimal?, date: Date))?)",
prefixForVariable: "_prefix_",
expectingVariableDeclaration: """
var _prefix_ReceivedInvocations: [(text: String, (Decimal?, date: Date))?] = []
"""
var _prefix_ReceivedInvocations: [(text: String, (Decimal?, date: Date))?] = []
"""
)
}

Expand Down Expand Up @@ -51,41 +51,45 @@ final class UT_ReceivedInvocationsFactory: XCTestCase {

func testVariableDeclarationMultiArguments() throws {
try assertProtocolFunction(
withFunctionDeclaration: "func foo(text: String, _ count: (x: Int, UInt?)?, final price: Decimal?)",
withFunctionDeclaration:
"func foo(text: String, _ count: (x: Int, UInt?)?, final price: Decimal?)",
prefixForVariable: "_prefix_",
expectingVariableDeclaration: """
var _prefix_ReceivedInvocations: [(text: String, count: (x: Int, UInt?)?, price: Decimal?)] = []
"""
var _prefix_ReceivedInvocations: [(text: String, count: (x: Int, UInt?)?, price: Decimal?)] = []
"""
)
}

func testVariableDeclarationMultiArgumentsWithEscapingAttribute() throws {
try assertProtocolFunction(
withFunctionDeclaration: "func foo(completion: @escaping () -> Void, count: UInt, final price: Decimal?)",
withFunctionDeclaration:
"func foo(completion: @escaping () -> Void, count: UInt, final price: Decimal?)",
prefixForVariable: "_prefix_",
expectingVariableDeclaration: """
var _prefix_ReceivedInvocations: [(completion: () -> Void, count: UInt, price: Decimal?)] = []
"""
var _prefix_ReceivedInvocations: [(completion: () -> Void, count: UInt, price: Decimal?)] = []
"""
)
}

func testVariableDeclarationMultiArgumentsWithSomeClosureArgument() throws {
try assertProtocolFunction(
withFunctionDeclaration: "func bar(completion: () -> Void, _ count: (x: Int, UInt?)?, final price: Decimal?)",
withFunctionDeclaration:
"func bar(completion: () -> Void, _ count: (x: Int, UInt?)?, final price: Decimal?)",
prefixForVariable: "_prefix_",
expectingVariableDeclaration: """
var _prefix_ReceivedInvocations: [(completion: () -> Void, count: (x: Int, UInt?)?, price: Decimal?)] = []
"""
var _prefix_ReceivedInvocations: [(completion: () -> Void, count: (x: Int, UInt?)?, price: Decimal?)] = []
"""
)
}

func testVariableDeclarationMultiArgumentsWithSomeOptionalClosureArgument() throws {
try assertProtocolFunction(
withFunctionDeclaration: "func func_name(completion: (() -> Void)?, _ count: (x: Int, UInt?)?, final price: Decimal?)",
withFunctionDeclaration:
"func func_name(completion: (() -> Void)?, _ count: (x: Int, UInt?)?, final price: Decimal?)",
prefixForVariable: "_prefix_",
expectingVariableDeclaration: """
var _prefix_ReceivedInvocations: [(completion: (() -> Void)?, count: (x: Int, UInt?)?, price: Decimal?)] = []
"""
var _prefix_ReceivedInvocations: [(completion: (() -> Void)?, count: (x: Int, UInt?)?, price: Decimal?)] = []
"""
)
}

Expand All @@ -109,7 +113,8 @@ final class UT_ReceivedInvocationsFactory: XCTestCase {

func testAppendValueToVariableExpressionMultiArguments() throws {
try assertProtocolFunction(
withFunctionDeclaration: "func foo(text: String, _ count: (x: Int, UInt?)?, final price: Decimal?)",
withFunctionDeclaration:
"func foo(text: String, _ count: (x: Int, UInt?)?, final price: Decimal?)",
prefixForVariable: "_prefix_",
expectingExpression: "_prefix_ReceivedInvocations.append((text, count, price))"
)
Expand Down
12 changes: 6 additions & 6 deletions Tests/SpyableMacroTests/Factories/UT_VariablePrefixFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ final class UT_VariablePrefixFactory: XCTestCase {
func testTextFunctionWithMultiArguments() throws {
try assertProtocolFunction(
withFunctionDeclaration: """
func foo(
text1 text2: String,
_ count2: Int,
product1 product2: (name: String, price: Decimal)
) -> String
""",
func foo(
text1 text2: String,
_ count2: Int,
product1 product2: (name: String, price: Decimal)
) -> String
""",
expectingVariableName: "fooText1Product1"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import XCTest
@testable import SpyableMacro

final class UT_VariablesImplementationFactory: XCTestCase {

// MARK: - Variables Declarations

func testVariablesDeclarations() throws {
try assertProtocolVariable(
withVariableDeclaration: "var point: (x: Int, y: Int?, (Int, Int)) { get }",
expectingVariableDeclaration: """
var point: (x: Int, y: Int?, (Int, Int)) {
get {
underlyingPoint
}
set {
underlyingPoint = newValue
}
}
var underlyingPoint: ((x: Int, y: Int?, (Int, Int)))!
"""
var point: (x: Int, y: Int?, (Int, Int)) {
get {
underlyingPoint
}
set {
underlyingPoint = newValue
}
}
var underlyingPoint: ((x: Int, y: Int?, (Int, Int)))!
"""
)
}

Expand All @@ -35,16 +35,16 @@ final class UT_VariablesImplementationFactory: XCTestCase {
try assertProtocolVariable(
withVariableDeclaration: "var completion: () -> Void { get }",
expectingVariableDeclaration: """
var completion: () -> Void {
get {
underlyingCompletion
}
set {
underlyingCompletion = newValue
}
}
var underlyingCompletion: (() -> Void)!
"""
var completion: () -> Void {
get {
underlyingCompletion
}
set {
underlyingCompletion = newValue
}
}
var underlyingCompletion: (() -> Void)!
"""
)
}

Expand All @@ -57,7 +57,7 @@ final class UT_VariablesImplementationFactory: XCTestCase {
)
) { error in
XCTAssertEqual(
error as! SpyableDiagnostic,
error as! SpyableDiagnostic,
SpyableDiagnostic.variableDeclInProtocolWithNotSingleBinding
)
}
Expand Down

0 comments on commit 52acf5a

Please sign in to comment.