Address PR comments.
This commit is contained in:
parent
fb5eb7936a
commit
5b1ed26237
|
@ -151,6 +151,7 @@
|
|||
6861B32D21A32279002EC2DA /* GenericProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6861B32B21A32279002EC2DA /* GenericProtocol.swift */; };
|
||||
6896352E21AC5A4700B25D47 /* GenericProtocolTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6896352D21AC5A4700B25D47 /* GenericProtocolTest.swift */; };
|
||||
6896352F21AC5A4700B25D47 /* GenericProtocolTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6896352D21AC5A4700B25D47 /* GenericProtocolTest.swift */; };
|
||||
68E9EAE6224B9F34000DBD29 /* StubFunctionThenThrowingTrait.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68E9EAE5224B9F34000DBD29 /* StubFunctionThenThrowingTrait.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
|
@ -360,6 +361,7 @@
|
|||
6861B30B21A31DA2002EC2DA /* GenericClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericClass.swift; sourceTree = "<group>"; };
|
||||
6861B32B21A32279002EC2DA /* GenericProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericProtocol.swift; sourceTree = "<group>"; };
|
||||
6896352D21AC5A4700B25D47 /* GenericProtocolTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericProtocolTest.swift; sourceTree = "<group>"; };
|
||||
68E9EAE5224B9F34000DBD29 /* StubFunctionThenThrowingTrait.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StubFunctionThenThrowingTrait.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -493,6 +495,7 @@
|
|||
18E2A2521FBB1C330058FEC5 /* StubFunctionThenReturnTrait.swift */,
|
||||
18E2A2531FBB1C330058FEC5 /* StubFunctionThenThrowTrait.swift */,
|
||||
18E2A2541FBB1C330058FEC5 /* StubFunctionThenTrait.swift */,
|
||||
68E9EAE5224B9F34000DBD29 /* StubFunctionThenThrowingTrait.swift */,
|
||||
);
|
||||
path = Trait;
|
||||
sourceTree = "<group>";
|
||||
|
@ -996,6 +999,7 @@
|
|||
18E2A3161FBB234F0058FEC5 /* StubCall.swift in Sources */,
|
||||
18E2A3051FBB23480058FEC5 /* StubFunctionThenDoNothingTrait.swift in Sources */,
|
||||
18E2A2FA1FBB23420058FEC5 /* ToBeStubbedProperty.swift in Sources */,
|
||||
68E9EAE6224B9F34000DBD29 /* StubFunctionThenThrowingTrait.swift in Sources */,
|
||||
18E2A31B1FBB23550058FEC5 /* Mock.swift in Sources */,
|
||||
18E2A3071FBB23480058FEC5 /* StubFunctionThenThrowTrait.swift in Sources */,
|
||||
18E2A3101FBB234B0058FEC5 /* StubThrowingFunction.swift in Sources */,
|
||||
|
|
|
@ -85,12 +85,3 @@ public struct MethodParameter: Token, Equatable {
|
|||
public func ==(lhs: MethodParameter, rhs: MethodParameter) -> Bool {
|
||||
return lhs.isEqual(to: rhs)
|
||||
}
|
||||
|
||||
import Foundation
|
||||
|
||||
extension String {
|
||||
func regexMatches(_ source: String) -> Bool {
|
||||
let regex = try! NSRegularExpression(pattern: self)
|
||||
return regex.firstMatch(in: source, range: NSRange(location: 0, length: source.count)) != nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,13 @@ extension String.UTF8View {
|
|||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
func regexMatches(_ source: String) -> Bool {
|
||||
let regex = try! NSRegularExpression(pattern: self)
|
||||
return regex.firstMatch(in: source, range: NSRange(location: 0, length: source.count)) != nil
|
||||
}
|
||||
}
|
||||
|
||||
extension Sequence {
|
||||
#if !swift(>=4.1)
|
||||
public func compactMap<O>(_ transform: (Element) -> O?) -> [O] {
|
||||
|
|
|
@ -9,19 +9,6 @@
|
|||
public protocol StubThrowingFunction: StubFunctionThenTrait, StubFunctionThenReturnTrait, StubFunctionThenThrowTrait, StubFunctionThenThrowingTrait {
|
||||
}
|
||||
|
||||
public protocol StubFunctionThenThrowingTrait: BaseStubFunctionTrait {
|
||||
/// Invokes throwing `implementation` when invoked.
|
||||
func then(_ implementation: @escaping (InputType) throws -> OutputType) -> Self
|
||||
}
|
||||
|
||||
public extension StubFunctionThenThrowingTrait {
|
||||
@discardableResult
|
||||
func then(_ implementation: @escaping (InputType) throws -> OutputType) -> Self {
|
||||
stub.appendAction(.callImplementation(implementation))
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
public struct ProtocolStubThrowingFunction<IN, OUT>: StubThrowingFunction {
|
||||
public let stub: ConcreteStub<IN, OUT>
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// StubFunctionThenThrowingTrait.swift
|
||||
// Cuckoo-iOS
|
||||
//
|
||||
// Created by Matyáš Kříž on 27/03/2019.
|
||||
//
|
||||
|
||||
public protocol StubFunctionThenThrowingTrait: BaseStubFunctionTrait {
|
||||
/// Invokes throwing `implementation` when invoked.
|
||||
func then(_ implementation: @escaping (InputType) throws -> OutputType) -> Self
|
||||
}
|
||||
|
||||
public extension StubFunctionThenThrowingTrait {
|
||||
@discardableResult
|
||||
func then(_ implementation: @escaping (InputType) throws -> OutputType) -> Self {
|
||||
stub.appendAction(.callImplementation(implementation))
|
||||
return self
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue