Skip to content

Commit

Permalink
Merge branch 'master' of github.com:krzysztofzablocki/Sourcery
Browse files Browse the repository at this point in the history
  • Loading branch information
art-divin committed Jan 22, 2024
2 parents db524bb + da95418 commit e7399d1
Show file tree
Hide file tree
Showing 5 changed files with 865 additions and 519 deletions.
2 changes: 1 addition & 1 deletion Templates/Templates/AutoMockable.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import {{ import }}
{% call accessLevel method.accessLevel %}{% call staticSpecifier method %}var {% call methodClosureName method %}: (({% for param in method.parameters %}{% call existentialClosureVariableTypeName param.typeName param.isVariadic %}{% if not forloop.last %}, {% endif %}{% endfor %}) {% if method.isAsync %}async {% endif %}{% if method.throws %}throws {% endif %}-> {% if method.isInitializer %}Void{% else %}{% call existentialVariableTypeName method.returnTypeName %}{% endif %})?
{% endmacro %}

{% macro methodClosureCallParameters method %}{% for param in method.parameters %}{{ param.name }}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %}
{% macro methodClosureCallParameters method %}{% for param in method.parameters %}{{ '&' if param.typeName.name | hasPrefix:"inout " }}{{ param.name }}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %}

{% macro mockMethod method %}
//MARK: - {{ method.shortName }}
Expand Down
5 changes: 5 additions & 0 deletions Templates/Tests/Context/AutoMockable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,8 @@ protocol SubscriptProtocol {
public protocol ProtocolWithMethodWithGenericParameters {
func execute(param: Result<Int, Error>) -> Result<String, Error>
}

// sourcery: AutoMockable
public protocol ProtocolWithMethodWithInoutParameter {
func execute(param: inout String)
}
5 changes: 5 additions & 0 deletions Templates/Tests/Context_Linux/AutoMockable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,8 @@ protocol SubscriptProtocol {
public protocol ProtocolWithMethodWithGenericParameters {
func execute(param: Result<Int, Error>) -> Result<String, Error>
}

// sourcery: AutoMockable
public protocol ProtocolWithMethodWithInoutParameter {
func execute(param: inout String)
}
27 changes: 26 additions & 1 deletion Templates/Tests/Expected/AutoMockable.expected
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 2.1.3 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.1.4 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
// swiftlint:disable line_length
// swiftlint:disable variable_name
Expand Down Expand Up @@ -1069,6 +1069,31 @@ public class ProtocolWithMethodWithGenericParametersMock: ProtocolWithMethodWith
}


}
public class ProtocolWithMethodWithInoutParameterMock: ProtocolWithMethodWithInoutParameter {

public init() {}



//MARK: - execute

public var executeParamInoutStringVoidCallsCount = 0
public var executeParamInoutStringVoidCalled: Bool {
return executeParamInoutStringVoidCallsCount > 0
}
public var executeParamInoutStringVoidReceivedParam: (String)?
public var executeParamInoutStringVoidReceivedInvocations: [(String)] = []
public var executeParamInoutStringVoidClosure: ((inout String) -> Void)?

public func execute(param: inout String) {
executeParamInoutStringVoidCallsCount += 1
executeParamInoutStringVoidReceivedParam = param
executeParamInoutStringVoidReceivedInvocations.append(param)
executeParamInoutStringVoidClosure?(&param)
}


}
public class ProtocolWithOverridesMock: ProtocolWithOverrides {

Expand Down
Loading

0 comments on commit e7399d1

Please sign in to comment.