TRAVIS_OS_NAME=osx <<<<<< ENV .swift-version Example.playground/Contents.swift Example.playground/contents.xcplayground InstantMock.podspec InstantMock.xcodeproj/project.pbxproj InstantMock.xcodeproj/project.xcworkspace/contents.xcworkspacedata InstantMock.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist InstantMock.xcodeproj/xcshareddata/xcschemes/InstantMock iOS.xcscheme InstantMock.xcodeproj/xcshareddata/xcschemes/InstantMock macOS.xcscheme InstantMock.xcodeproj/xcshareddata/xcschemes/InstantMock tvOS.xcscheme InstantMock.xcodeproj/xcshareddata/xcschemes/InstantMockTests iOS.xcscheme InstantMock.xcodeproj/xcshareddata/xcschemes/InstantMockTests macOS.xcscheme InstantMock.xcodeproj/xcshareddata/xcschemes/InstantMockTests tvOS.xcscheme InstantMock.xcworkspace/contents.xcworkspacedata InstantMock.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist InstantMock.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings LICENSE Package.swift Sources/Info.plist Sources/InstantMock.h Sources/InstantMock/Arguments/Arg+Closure.swift Sources/InstantMock/Arguments/Arg.swift Sources/InstantMock/Arguments/Argument/Argument.swift Sources/InstantMock/Arguments/Argument/ArgumentAny.swift Sources/InstantMock/Arguments/Argument/ArgumentCapture.swift Sources/InstantMock/Arguments/Argument/ArgumentClosure.swift Sources/InstantMock/Arguments/Argument/ArgumentValue.swift Sources/InstantMock/Arguments/Argument/ArgumentVerify/ArgumentVerify.swift Sources/InstantMock/Arguments/Argument/ArgumentVerify/ArgumentVerifyMandatory.swift Sources/InstantMock/Arguments/Argument/ArgumentVerify/ArgumentVerifyOptional.swift Sources/InstantMock/Arguments/Captor/ArgumentCaptor.swift Sources/InstantMock/Arguments/Captor/ArgumentCaptorValues.swift Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor.swift Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+FiveArgs.swift Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+FourArgs.swift Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+NoArg.swift Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+OneArg.swift Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+ThreeArgs.swift Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+TwoArgs.swift Sources/InstantMock/Arguments/Helpers/ArgumentFactory.swift Sources/InstantMock/Arguments/Helpers/ArgumentStorage.swift Sources/InstantMock/Arguments/Helpers/ArgumentsConfiguration.swift Sources/InstantMock/Arguments/Helpers/ArgumentsMatcher.swift Sources/InstantMock/DefaultValue/DefaultClosureHandler.swift Sources/InstantMock/DefaultValue/DefaultValueHandler.swift Sources/InstantMock/Factories/ExpectationFactory.swift Sources/InstantMock/Interceptors/CallInterceptor.swift Sources/InstantMock/Interceptors/Expectation.swift Sources/InstantMock/Interceptors/Helpers/CallConfiguration.swift Sources/InstantMock/Interceptors/Helpers/CallInterceptorStorage.swift Sources/InstantMock/Interceptors/Stub.swift Sources/InstantMock/Mock.swift Sources/InstantMock/MockUsable/Array+MockUsable.swift Sources/InstantMock/MockUsable/Bool+MockUsable.swift Sources/InstantMock/MockUsable/Date+MockUsable.swift Sources/InstantMock/MockUsable/Dictionary+MockUsable.swift Sources/InstantMock/MockUsable/Double+MockUsable.swift Sources/InstantMock/MockUsable/Float+MockUsable.swift Sources/InstantMock/MockUsable/Int+MockUsable.swift Sources/InstantMock/MockUsable/MockUsable.swift Sources/InstantMock/MockUsable/Set+MockUsable.swift Sources/InstantMock/MockUsable/String+MockUsable.swift Sources/InstantMock/Property/Property.swift Sources/InstantMock/Verifications/Assertion.swift Sources/InstantMock/Verifications/Verifier.swift Tests/Info.plist Tests/InstantMockTests/Integration Tests/BasicMockTests.swift Tests/InstantMockTests/Integration Tests/CaptureMockTests.swift Tests/InstantMockTests/Integration Tests/ClosureMockTests.swift Tests/InstantMockTests/Integration Tests/MockCreationModalityTests.swift Tests/InstantMockTests/Integration Tests/ThrowingMockTests.swift Tests/InstantMockTests/Integration Tests/TypesMockTests.swift Tests/InstantMockTests/Integration Tests/VerifyMockTests.swift Tests/InstantMockTests/Mocks/ArgumentAnyMock.swift Tests/InstantMockTests/Mocks/ArgumentCaptureMock.swift Tests/InstantMockTests/Mocks/ArgumentClosureMock.swift Tests/InstantMockTests/Mocks/ArgumentFactoryMock.swift Tests/InstantMockTests/Mocks/ArgumentStorageMock.swift Tests/InstantMockTests/Mocks/ArgumentValueMock.swift Tests/InstantMockTests/Mocks/ArgumentVerifyMandatoryMock.swift Tests/InstantMockTests/Mocks/ArgumentVerifyOptionalMock.swift Tests/InstantMockTests/Mocks/AssertionMock.swift Tests/InstantMockTests/Mocks/ExpectationFactoryMock.swift Tests/InstantMockTests/Mocks/VerifierMock.swift Tests/InstantMockTests/Unit Tests/Arguments/Arg+ClosureTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentAnyTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentCaptureTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentClosureTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentValueTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentVerifyMandatoryTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentVerifyOptionalTests.swift Tests/InstantMockTests/Unit Tests/Arguments/ArgTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentCaptorTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentCaptorValuesTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+TwoArgs.swift Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptorTests+FiveArgs.swift Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptorTests+FourArgs.swift Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptorTests+NoArg.swift Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptorTests+OneArg.swift Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptorTests+ThreeArgs.swift Tests/InstantMockTests/Unit Tests/Arguments/Helpers/ArgumentStorageTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Helpers/ArgumentsConfigurationTests.swift Tests/InstantMockTests/Unit Tests/Arguments/Helpers/ArgumentsMatcherTests.swift Tests/InstantMockTests/Unit Tests/DefaultValue/DefaultClosureHandlerTests.swift Tests/InstantMockTests/Unit Tests/DefaultValue/DefaultValueHandlerTests.swift Tests/InstantMockTests/Unit Tests/Factories/ExpectationFactoryTests.swift Tests/InstantMockTests/Unit Tests/Interceptors/CallInterceptorStorageTests.swift Tests/InstantMockTests/Unit Tests/Interceptors/CallInterceptorTests.swift Tests/InstantMockTests/Unit Tests/Interceptors/ExpectationTests.swift Tests/InstantMockTests/Unit Tests/Interceptors/Helpers/CallConfigurationTests.swift Tests/InstantMockTests/Unit Tests/Interceptors/StubTests.swift Tests/InstantMockTests/Unit Tests/MockUsable/ArrayMockUsableTests.swift Tests/InstantMockTests/Unit Tests/MockUsable/BoolMockUsableTests.swift Tests/InstantMockTests/Unit Tests/MockUsable/DateMockUsableTests.swift Tests/InstantMockTests/Unit Tests/MockUsable/DictionaryMockUsableTests.swift Tests/InstantMockTests/Unit Tests/MockUsable/DoubleMockUsableTests.swift Tests/InstantMockTests/Unit Tests/MockUsable/FloatMockUsableTests.swift Tests/InstantMockTests/Unit Tests/MockUsable/IntMockUsableTests.swift Tests/InstantMockTests/Unit Tests/MockUsable/SetMockUsableTests.swift Tests/InstantMockTests/Unit Tests/MockUsable/StringMockUsableTests.swift Tests/InstantMockTests/Unit Tests/Verifications/VerifierTests.swift Tests/InstantMockTests/XCTestManifests.swift Tests/LinuxMain.swift ci/after_success.sh ci/install.sh ci/script.sh <<<<<< network # path=./InstantMock.framework.coverage.txt /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Arg+Closure.swift: 1| |// 2| |// Arg+Closure.swift 3| |// InstantMock iOS 4| |// 5| |// Created by Patrick on 18/07/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension for Arg, dedicated to matching a closure */ 11| |extension Arg { 12| | 13| | /** Register a closure with no arg */ 14| 1| public static func closure() -> T where T == () -> Ret { 15| 1| let factory = ArgumentFactoryImpl() 16| 1| return Arg.closure(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as () -> Ret 17| 1| } 18| | 19| | 20| | /** Register a closure with one arg (for dependency injection) */ 21| | static func closure(argFactory: F, argStorage: ArgumentStorage) -> () -> Ret 22| 2| where F: ArgumentFactory, F.Value == T { 23| 2| 24| 2| // create and store instance 25| 2| let typeDescription = "\(T.self)" 26| 2| let arg = argFactory.argumentClosure(typeDescription) 27| 2| argStorage.store(arg) 28| 2| 29| 2| // return default value 30| 2| return DefaultClosureHandler.it() as () -> Ret 31| 2| } 32| | 33| | 34| | /** Register a closure with one arg */ 35| 1| public static func closure() -> T where T == (Arg1) -> Ret { 36| 1| let factory = ArgumentFactoryImpl() 37| 1| return Arg.closure(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as (Arg1) -> Ret 38| 1| } 39| | 40| | 41| | /** Register a closure with one arg (for dependency injection) */ 42| | static func closure(argFactory: F, argStorage: ArgumentStorage) -> (Arg1) -> Ret 43| 2| where F: ArgumentFactory, F.Value == T { 44| 2| 45| 2| // create and store instance 46| 2| let typeDescription = "\(T.self)" 47| 2| let arg = argFactory.argumentClosure(typeDescription) 48| 2| argStorage.store(arg) 49| 2| 50| 2| // return default value 51| 2| return DefaultClosureHandler.it() as (Arg1) -> Ret 52| 2| } 53| | 54| | 55| | /** Register a closure with two args */ 56| 4| public static func closure() -> T where T == (Arg1, Arg2) -> Ret { 57| 4| let factory = ArgumentFactoryImpl() 58| 4| return Arg.closure(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as (Arg1, Arg2) -> Ret 59| 4| } 60| | 61| | 62| | /** Register a closure with two args (for dependency injection) */ 63| | static func closure(argFactory: F, argStorage: ArgumentStorage) -> (Arg1, Arg2) -> Ret 64| 5| where F: ArgumentFactory, F.Value == T { 65| 5| 66| 5| // create and store instance 67| 5| let typeDescription = "\(T.self)" 68| 5| let arg = argFactory.argumentClosure(typeDescription) 69| 5| argStorage.store(arg) 70| 5| 71| 5| // return default value 72| 5| return DefaultClosureHandler.it() as (Arg1, Arg2) -> Ret 73| 5| } 74| | 75| | 76| | /** Register a closure with three args */ 77| 1| public static func closure() -> T where T == (Arg1, Arg2, Arg3) -> Ret { 78| 1| let factory = ArgumentFactoryImpl() 79| 1| return Arg.closure(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as (Arg1, Arg2, Arg3) -> Ret 80| 1| } 81| | 82| | 83| | /** Register a closure with three args (for dependency injection) */ 84| | static func closure(argFactory: F, argStorage: ArgumentStorage) 85| 2| -> (Arg1, Arg2, Arg3) -> Ret where F: ArgumentFactory, F.Value == T { 86| 2| 87| 2| // create and store instance 88| 2| let typeDescription = "\(T.self)" 89| 2| let arg = argFactory.argumentClosure(typeDescription) 90| 2| argStorage.store(arg) 91| 2| 92| 2| // return default value 93| 2| return DefaultClosureHandler.it() as (Arg1, Arg2, Arg3) -> Ret 94| 2| } 95| | 96| | 97| | /** Register a closure with four args */ 98| 1| public static func closure() -> T where T == (Arg1, Arg2, Arg3, Arg4) -> Ret { 99| 1| let factory = ArgumentFactoryImpl() 100| 1| return Arg.closure(argFactory: factory, argStorage: ArgumentStorageImpl.instance) 101| 1| as (Arg1, Arg2, Arg3, Arg4) -> Ret 102| 1| } 103| | 104| | 105| | /** Register a closure with four args (for dependency injection) */ 106| | static func closure(argFactory: F, argStorage: ArgumentStorage) 107| 2| -> (Arg1, Arg2, Arg3, Arg4) -> Ret where F: ArgumentFactory, F.Value == T { 108| 2| 109| 2| // create and store instance 110| 2| let typeDescription = "\(T.self)" 111| 2| let arg = argFactory.argumentClosure(typeDescription) 112| 2| argStorage.store(arg) 113| 2| 114| 2| // return default value 115| 2| return DefaultClosureHandler.it() as (Arg1, Arg2, Arg3, Arg4) -> Ret 116| 2| } 117| | 118| | 119| | /** Register a closure with five args */ 120| | public static func closure() -> T 121| 1| where T == (Arg1, Arg2, Arg3, Arg4, Arg5) -> Ret { 122| 1| 123| 1| let factory = ArgumentFactoryImpl() 124| 1| return Arg.closure(argFactory: factory, argStorage: ArgumentStorageImpl.instance) 125| 1| as (Arg1, Arg2, Arg3, Arg4, Arg5) -> Ret 126| 1| } 127| | 128| | 129| | /** Register a closure with two args (for dependency injection) */ 130| | static func closure(argFactory: F, argStorage: ArgumentStorage) 131| 2| -> (Arg1, Arg2, Arg3, Arg4, Arg5) -> Ret where F: ArgumentFactory, F.Value == T { 132| 2| 133| 2| // create and store instance 134| 2| let typeDescription = "\(T.self)" 135| 2| let arg = argFactory.argumentClosure(typeDescription) 136| 2| argStorage.store(arg) 137| 2| 138| 2| // return default value 139| 2| return DefaultClosureHandler.it() as (Arg1, Arg2, Arg3, Arg4, Arg5) -> Ret 140| 2| } 141| | 142| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Arg.swift: 1| |// 2| |// Arg.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 12/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** This class represents a generic Argument being registered */ 11| |public final class Arg { 12| | 13| | 14| | // MARK: Arguments matching exact values 15| | 16| | /** Register a mandatory value */ 17| 20| public static func eq(_ val: T) -> T { 18| 20| let factory = ArgumentFactoryImpl() 19| 20| return Arg.eq(val, argFactory: factory, argStorage: ArgumentStorageImpl.instance) 20| 20| } 21| | 22| | 23| | /** Register an optional value */ 24| 2| public static func eq(_ val: T?) -> T? { 25| 2| let factory = ArgumentFactoryImpl() 26| 2| return Arg.eq(val, argFactory: factory, argStorage: ArgumentStorageImpl.instance) 27| 2| } 28| | 29| | 30| | /** Register a mandatory value with factory (for dependency injection) */ 31| | static func eq(_ val: T, argFactory: F, argStorage: ArgumentStorage) -> T 32| 24| where F: ArgumentFactory, F.Value == T { 33| 24| 34| 24| let arg = argFactory.argument(value: val) 35| 24| argStorage.store(arg) 36| 24| return val 37| 24| } 38| | 39| | 40| | /** Register an optional value with factory (for dependency injection) */ 41| | static func eq(_ val: T?, argFactory: F, argStorage: ArgumentStorage) -> T? 42| 4| where F: ArgumentFactory, F.Value == T { 43| 4| 44| 4| let arg = argFactory.argument(value: val) 45| 4| argStorage.store(arg) 46| 4| return val 47| 4| } 48| | 49| | 50| | // MARK: Arguments matching a condition 51| | 52| | /** Register a closure to be verified, with mandatory type */ 53| 3| public static func verify(_ condition: @escaping (T) -> Bool) -> T { 54| 3| let factory = ArgumentFactoryImpl() 55| 3| return Arg.verify(condition, argFactory: factory, argStorage: ArgumentStorageImpl.instance) 56| 3| } 57| | 58| | 59| | /** Register a closure to be verified, with optional type */ 60| 2| public static func verify(_ condition: @escaping (T?) -> Bool) -> T? { 61| 2| let factory = ArgumentFactoryImpl() 62| 2| return Arg.verify(condition, argFactory: factory, argStorage: ArgumentStorageImpl.instance) 63| 2| } 64| | 65| | 66| | /** Register a closure to be verified, with mandatory type */ 67| | static func verify(_ condition: @escaping (T) -> Bool, argFactory: F, argStorage: ArgumentStorage) -> T 68| 5| where F: ArgumentFactory, F.Value == T { 69| 5| 70| 5| let arg = argFactory.argument(condition: condition) 71| 5| argStorage.store(arg) 72| 5| 73| 5| // return default value 74| 5| guard let ret = DefaultValueHandler().it else { 75| 0| fatalError("Unexpected type, only `MockUsable` types can be used with `verify`") 76| 5| } 77| 5| return ret 78| 5| } 79| | 80| | 81| | /** Register a closure to be verified, with optional type */ 82| | static func verify(_ condition: @escaping (T?) -> Bool, argFactory: F, argStorage: ArgumentStorage) -> T? 83| 2| where F: ArgumentFactory, F.Value == T { 84| 2| 85| 2| // create and store instance 86| 2| let arg = argFactory.argument(condition: condition) 87| 2| argStorage.store(arg) 88| 2| 89| 2| // return default nil value 90| 2| return nil 91| 2| } 92| | 93| |} 94| | 95| | 96| |/** Extension for `MockUsable` args */ 97| |extension Arg where T: MockUsable { 98| | 99| | 100| | // MARK: Arguments matching any values 101| | 102| | /** Register any value returning mandatory value */ 103| 35| public static func any() -> T { 104| 35| let factory = ArgumentFactoryImpl() 105| 35| return Arg.any(argFactory: factory, argStorage: ArgumentStorageImpl.instance) 106| 35| } 107| | 108| | 109| | /** Register any value returning optional value */ 110| 4| public static func any() -> T? { 111| 4| let factory = ArgumentFactoryImpl() 112| 4| return Arg.any(argFactory: factory, argStorage: ArgumentStorageImpl.instance) 113| 4| } 114| | 115| | 116| | /** Register any value (for dependency injection) */ 117| 42| static func any(argFactory: F, argStorage: ArgumentStorage) -> T where F: ArgumentFactory, F.Value == T { 118| 42| 119| 42| // create and store instance 120| 42| let typeDescription = "\(T.self)" 121| 42| let arg = argFactory.argumentAny(typeDescription) 122| 42| argStorage.store(arg) 123| 42| 124| 42| // return default value 125| 42| guard let ret = DefaultValueHandler().it else { 126| 0| fatalError("Unexpected type, only `MockUsable` types can be used with `any`") 127| 42| } 128| 42| return ret 129| 42| } 130| | 131| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Argument/ArgumentAny.swift: 1| |// 2| |// ArgumentAny.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 12/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Main protocol for an argument that verifies any values */ 11| |public protocol ArgumentAny: Argument {} 12| | 13| | 14| |/** Main implementation of the configuration of an argument that verifies any values */ 15| |final class ArgumentAnyImpl: ArgumentAny { 16| | 17| | /// Type description for the arg 18| | private let typeDescription: String 19| | 20| | 21| | /** Initialize with given type description */ 22| 41| init(_ typeDescription: String) { 23| 41| self.typeDescription = typeDescription 24| 41| } 25| | 26| |} 27| | 28| | 29| |/** Extension that performs matching */ 30| |extension ArgumentAnyImpl: ArgumentMatching { 31| | 32| 77| func match(_ value: Any?) -> Bool { 33| 77| return true 34| 77| } 35| | 36| |} 37| | 38| | 39| |/** Extension to return a description */ 40| |extension ArgumentAnyImpl: CustomStringConvertible { 41| | 42| 22| var description: String { 43| 22| return "any<\(self.typeDescription)>" 44| 22| } 45| | 46| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Argument/ArgumentCapture.swift: 1| |// 2| |// ArgumentCapture.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 12/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Protocol for capturing arguments */ 11| |public protocol ArgumentCapture: Argument { 12| | func setValue(_ value: Any?) 13| | var allValues: [Any?] { get } 14| | var value: Any? { get } 15| |} 16| | 17| | 18| |/** This class represents the configuration of an argument that captures passed values */ 19| |final class ArgumentCaptureImpl: ArgumentCapture { 20| | 21| | /// Type description for the arg 22| | private let typeDescription: String 23| | 24| | /// Inner captured values 25| | private var values = [T?]() 26| | 27| | /// Last captured value 28| 35| var value: Any? { 29| 35| return self.valueTyped 30| 35| } 31| | 32| | /// Last captured value (typed) 33| 37| var valueTyped: T? { 34| 37| var ret: T? 35| 37| if let val = self.values.last { 36| 35| ret = val 37| 37| } 38| 37| return ret 39| 37| } 40| | 41| | /// All captured values 42| 23| var allValues: [Any?] { 43| 23| return self.allValuesTyped 44| 23| } 45| | 46| | /// All captured values (typed) 47| 24| var allValuesTyped: [T?] { 48| 24| return values 49| 24| } 50| | 51| | 52| | // MARK: Initializer 53| | 54| | /** Initialize with given type description */ 55| 25| init(_ typeDescription: String) { 56| 25| self.typeDescription = typeDescription 57| 25| } 58| | 59| |} 60| | 61| | 62| |/** Extension that performs matching */ 63| |extension ArgumentCaptureImpl: ArgumentMatching { 64| | 65| 35| func match(_ value: Any?) -> Bool { 66| 35| // all capture objects match anything 67| 35| return true 68| 35| } 69| | 70| |} 71| | 72| | 73| |/** Extension that sets a captured value */ 74| |extension ArgumentCaptureImpl { 75| | 76| 24| func setValue(_ value: Any?) { 77| 24| if value == nil { 78| 1| self.values.append(nil as T?) 79| 24| } else if let tValue = value as? T { 80| 22| self.values.append(tValue) 81| 24| } 82| 24| } 83| | 84| |} 85| | 86| | 87| |/** Extension to return a description */ 88| |extension ArgumentCaptureImpl: CustomStringConvertible { 89| | 90| 1| var description: String { 91| 1| return "captured<\(typeDescription)>" 92| 1| } 93| | 94| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Argument/ArgumentClosure.swift: 1| |// 2| |// ArgumentClosure.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 21/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Main protocol for an argument that verifies a closure */ 11| |public protocol ArgumentClosure: Argument {} 12| | 13| | 14| |/** Main implementation of the configuration of an argument that verifies a closure */ 15| |final class ArgumentClosureImpl: ArgumentClosure { 16| | 17| | /// Type description for the arg 18| | private let typeDescription: String 19| | 20| | 21| | /** Initialize with given type description */ 22| 11| init(_ typeDescription: String) { 23| 11| self.typeDescription = typeDescription 24| 11| } 25| | 26| |} 27| | 28| | 29| |/** Extension that performs matching */ 30| |extension ArgumentClosureImpl: ArgumentMatching { 31| | 32| 19| func match(_ value: Any?) -> Bool { 33| 19| return true 34| 19| } 35| | 36| |} 37| | 38| | 39| |/** Extension to return a description */ 40| |extension ArgumentClosureImpl: CustomStringConvertible { 41| | 42| 1| var description: String { 43| 1| return "closure<\(self.typeDescription)>" 44| 1| } 45| | 46| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Argument/ArgumentValue.swift: 1| |// 2| |// ArgumentValue.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 12/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Main protocol for an argument that must verify a precise value */ 11| |public protocol ArgumentValue: Argument {} 12| | 13| | 14| |/** Protocol for an argument that must verify a precise value of given type */ 15| |public protocol ArgumentValueTyped: ArgumentValue { 16| | associatedtype Value 17| | var value: Value? { get } 18| | init(_ value: Value?) 19| |} 20| | 21| | 22| |/** Main implementation of the configuration of an argument that must verify a precise value */ 23| |final class ArgumentValueImpl: ArgumentValueTyped { 24| | 25| | /// Value that must match 26| | let value: T? 27| | 28| | /// Verifier to be used for the match 29| | private let verifier: Verifier 30| | 31| | 32| | // MARK: Initializers 33| | 34| | /** Initialize new instance with provided value */ 35| 22| convenience required init(_ value: T?) { 36| 22| self.init(value, verifier: VerifierImpl.instance) 37| 22| } 38| | 39| | /** For dependency injection */ 40| 25| init(_ value: T?, verifier: Verifier) { 41| 25| self.value = value 42| 25| self.verifier = verifier 43| 25| } 44| | 45| |} 46| | 47| | 48| |/** Extension that performs matching */ 49| |extension ArgumentValueImpl: ArgumentMatching { 50| | 51| 43| func match(_ value: Any?) -> Bool { 52| 43| return self.verifier.equal(value, to: self.value) 53| 43| } 54| | 55| |} 56| | 57| | 58| |/** Extension to return a description */ 59| |extension ArgumentValueImpl: CustomStringConvertible { 60| | 61| 9| var description: String { 62| 9| var ret = "" 63| 9| 64| 9| if let value = self.value { 65| 8| ret = "\(value)" 66| 9| } else { 67| 1| ret = "nil" 68| 9| } 69| 9| 70| 9| return ret 71| 9| } 72| | 73| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Argument/ArgumentVerify/ArgumentVerifyMandatory.swift: 1| |// 2| |// ArgumentVerifyMandatory.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 20/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Protocol for an argument that must verify a precise condition of given mandatory type */ 11| |public protocol ArgumentVerifyMandatoryTyped: ArgumentVerify { 12| | associatedtype Value 13| | var condition: ((Value) -> Bool) { get } 14| | init(_ condition: @escaping ((Value) -> Bool)) 15| |} 16| | 17| | 18| |/** Main implementation of the configuration of an argument that must verify a precise condition */ 19| |final class ArgumentVerifyMandatoryImpl: ArgumentVerifyMandatoryTyped { 20| | 21| | /// Condition that must be verified 22| | let condition: ((T) -> Bool) 23| | 24| | 25| | /** Initialize new instance with provided condition */ 26| 6| required init(_ condition: @escaping ((T) -> Bool)) { 27| 6| self.condition = condition 28| 6| } 29| | 30| |} 31| | 32| | 33| |/** Extension that performs matching */ 34| |extension ArgumentVerifyMandatoryImpl: ArgumentMatching { 35| | 36| 14| func match(_ value: Any?) -> Bool { 37| 14| var ret = false 38| 14| 39| 14| // make sure to have a condition and that value matches the required type 40| 14| if let tValue = value as? T { 41| 13| ret = self.condition(tValue) // evaluate the condition 42| 14| } 43| 14| 44| 14| return ret 45| 14| } 46| | 47| |} 48| | 49| | 50| |/** Extension to return a description */ 51| |extension ArgumentVerifyMandatoryImpl: CustomStringConvertible { 52| | 53| 3| var description: String { 54| 3| return "conditioned<\(type(of: self.condition))>" 55| 3| } 56| | 57| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Argument/ArgumentVerify/ArgumentVerifyOptional.swift: 1| |// 2| |// ArgumentVerifyOptional.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 20/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Protocol for an argument that must verify a precise condition of given optional type */ 11| |public protocol ArgumentVerifyOptionalTyped: ArgumentVerify { 12| | associatedtype Value 13| | var condition: ((Value?) -> Bool) { get } 14| | init(_ condition: @escaping ((Value?) -> Bool)) 15| |} 16| | 17| | 18| |/** Main implementation of the configuration of an argument that must verify a precise condition */ 19| |final class ArgumentVerifyOptionalImpl: ArgumentVerifyOptionalTyped { 20| | 21| | /// Condition that must be verified 22| | let condition: ((T?) -> Bool) 23| | 24| | 25| | /** Initialize new instance with provided condition */ 26| 6| required init(_ condition: @escaping ((T?) -> Bool)) { 27| 6| self.condition = condition 28| 6| } 29| | 30| |} 31| | 32| | 33| |/** Extension that performs matching */ 34| |extension ArgumentVerifyOptionalImpl: ArgumentMatching { 35| | 36| 11| func match(_ value: Any?) -> Bool { 37| 11| var ret = false 38| 11| 39| 11| // make sure to have a condition and that value matches the required type 40| 11| if let tValue = value as? T? { 41| 10| ret = self.condition(tValue) // evaluate the condition 42| 11| } 43| 11| 44| 11| return ret 45| 11| } 46| | 47| |} 48| | 49| | 50| |/** Extension to return a description */ 51| |extension ArgumentVerifyOptionalImpl: CustomStringConvertible { 52| | 53| 3| var description: String { 54| 3| return "conditioned<\(type(of: self.condition))>" 55| 3| } 56| | 57| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Captor/ArgumentCaptor.swift: 1| |// 2| |// ArgumentCaptor.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 12/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** This class enables to capture arguments of any types (except closures) */ 11| |public final class ArgumentCaptor { 12| | 13| | /// Argument that captures values 14| | private var arg: ArgumentCapture? 15| | 16| | /// Delegate for returning captured values 17| 4| private lazy var delegate: ArgumentCaptorValuesImpl = { 18| 4| return ArgumentCaptorValuesImpl(self.arg) 19| 4| }() 20| | 21| | /** Main initializer */ 22| 5| public init() {} 23| | 24| |} 25| | 26| | 27| |/** Extension that performs the actual capture */ 28| |extension ArgumentCaptor { 29| | 30| | /** Capture an argument of expected type */ 31| 2| public func capture() -> T { 32| 2| let factory = ArgumentFactoryImpl() 33| 2| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) 34| 2| } 35| | 36| | 37| | /** Capture an argument of expected type (for dependency injection) */ 38| 6| func capture(argFactory: F, argStorage: ArgumentStorage) -> T where F: ArgumentFactory, F.Value == T { 39| 6| 40| 6| // store instance 41| 6| let typeDescription = "\(T.self)" 42| 6| let arg = argFactory.argumentCapture(typeDescription) 43| 6| self.arg = arg 44| 6| argStorage.store(arg) 45| 6| 46| 6| // otherwise, try to guess the default value from required type 47| 6| guard let ret = DefaultValueHandler().it else { 48| 0| fatalError("Unexpected type, only `MockUsable` types can be used with `captors`") 49| 6| } 50| 6| return ret 51| 6| } 52| | 53| |} 54| | 55| | 56| |/** Extension for returning captured valued */ 57| |extension ArgumentCaptor: ArgumentCaptorValues { 58| | 59| 5| public var value: T? { 60| 5| return self.delegate.value 61| 5| } 62| | 63| 5| public var allValues: [T?] { 64| 5| return self.delegate.allValues 65| 5| } 66| | 67| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Captor/ArgumentCaptorValues.swift: 1| |// 2| |// ArgumentCaptorValues.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 21/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Protocol for returning captured values */ 11| |protocol ArgumentCaptorValues { 12| | associatedtype Value 13| | var value: Value? { get } 14| | var allValues: [Value?] { get } 15| |} 16| | 17| | 18| |/** Main implementation for returning captured values */ 19| |public final class ArgumentCaptorValuesImpl: ArgumentCaptorValues { 20| | 21| | /// Argument capture instance 22| | private var arg: ArgumentCapture? 23| | 24| | /// Captured value 25| 40| public var value: T? { 26| 40| var ret: T? 27| 40| if let captureArg = self.arg { 28| 39| ret = captureArg.value as? T 29| 40| } 30| 40| return ret 31| 40| } 32| | 33| | /// All captured values 34| 27| public var allValues: [T?] { 35| 27| var ret = [T?]() 36| 27| if let captureArg = self.arg { 37| 28| ret = captureArg.allValues.map { $0 as? T }.compactMap { $0 } 38| 27| } 39| 27| return ret 40| 27| } 41| | 42| | 43| | /** Initializer */ 44| 33| init(_ arg: ArgumentCapture?) { 45| 33| self.arg = arg 46| 33| } 47| | 48| |} 49| | /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor.swift: 1| |// 2| |// ArgumentClosureCaptor.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 21/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** This class enables to capture arguments of type closure */ 11| |public final class ArgumentClosureCaptor { 12| | 13| | /// Argument that captures values 14| | var arg: ArgumentCapture? 15| | 16| | /// Delegate for returning captured values 17| 25| private lazy var delegate: ArgumentCaptorValuesImpl = { 18| 25| return ArgumentCaptorValuesImpl(self.arg) 19| 25| }() 20| | 21| | /** Main initializer */ 22| 31| public init() {} 23| | 24| |} 25| | 26| | 27| |/** Extension for returning captured valued */ 28| |extension ArgumentClosureCaptor: ArgumentCaptorValues { 29| | 30| 32| public var value: T? { 31| 32| return self.delegate.value 32| 32| } 33| | 34| 19| public var allValues: [T?] { 35| 19| return self.delegate.allValues 36| 19| } 37| | 38| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+FiveArgs.swift: 1| |// 2| |// ArgumentClosureCaptor+FiveArgs.swift 3| |// InstantMock iOS 4| |// 5| |// Created by Patrick on 22/07/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension that performs the actual capture for five args */ 11| |extension ArgumentClosureCaptor { 12| | 13| | 14| | /** Capture a closure of expected type */ 15| 1| public func capture() -> T where T == (Arg1, Arg2, Arg3, Arg4, Arg5) -> Ret { 16| 1| let factory = ArgumentFactoryImpl() 17| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) 18| 1| as (Arg1, Arg2, Arg3, Arg4, Arg5) -> Ret 19| 1| } 20| | 21| | 22| | /** Capture a closure of expected type that can throw */ 23| | public func capture() -> T 24| | where T == (Arg1, Arg2, Arg3, Arg4, Arg5) throws -> Ret 25| 1| { 26| 1| let factory = ArgumentFactoryImpl() 27| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) 28| 1| as (Arg1, Arg2, Arg3, Arg4, Arg5) throws -> Ret 29| 1| } 30| | 31| | 32| | /** Capture an argument of expected type (for dependency injection) */ 33| | func capture(argFactory: F, argStorage: ArgumentStorage) 34| 6| -> (Arg1, Arg2, Arg3, Arg4, Arg5) -> Ret where F: ArgumentFactory, F.Value == T { 35| 6| 36| 6| // store instance 37| 6| let typeDescription = "\(T.self)" 38| 6| let arg = argFactory.argumentCapture(typeDescription) 39| 6| self.arg = arg 40| 6| argStorage.store(arg) 41| 6| 42| 6| return DefaultClosureHandler.it() as (Arg1, Arg2, Arg3, Arg4, Arg5) -> Ret 43| 6| } 44| | 45| |} 46| | /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+FourArgs.swift: 1| |// 2| |// ArgumentClosureCaptor+FourArgs.swift 3| |// InstantMock iOS 4| |// 5| |// Created by Patrick on 22/07/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension that performs the actual capture for four args */ 11| |extension ArgumentClosureCaptor { 12| | 13| | 14| | /** Capture a closure of expected type */ 15| 1| public func capture() -> T where T == (Arg1, Arg2, Arg3, Arg4) -> Ret { 16| 1| let factory = ArgumentFactoryImpl() 17| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) 18| 1| as (Arg1, Arg2, Arg3, Arg4) -> Ret 19| 1| } 20| | 21| | 22| | /** Capture a closure of expected type that can throw */ 23| 1| public func capture() -> T where T == (Arg1, Arg2, Arg3, Arg4) throws -> Ret { 24| 1| let factory = ArgumentFactoryImpl() 25| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) 26| 1| as (Arg1, Arg2, Arg3, Arg4) throws -> Ret 27| 1| } 28| | 29| | 30| | /** Capture an argument of expected type (for dependency injection) */ 31| | func capture(argFactory: F, argStorage: ArgumentStorage) 32| 6| -> (Arg1, Arg2, Arg3, Arg4) -> Ret where F: ArgumentFactory, F.Value == T { 33| 6| 34| 6| // store instance 35| 6| let typeDescription = "\(T.self)" 36| 6| let arg = argFactory.argumentCapture(typeDescription) 37| 6| self.arg = arg 38| 6| argStorage.store(arg) 39| 6| 40| 6| return DefaultClosureHandler.it() as (Arg1, Arg2, Arg3, Arg4) -> Ret 41| 6| } 42| | 43| |} 44| | /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+NoArg.swift: 1| |// 2| |// ArgumentClosureCaptor+NoArg.swift 3| |// InstantMock iOS 4| |// 5| |// Created by Patrick on 22/07/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension that performs the actual capture for no arg */ 11| |extension ArgumentClosureCaptor { 12| | 13| | 14| | /** Capture a closure of expected type */ 15| 1| public func capture() -> T where T == () -> Ret { 16| 1| let factory = ArgumentFactoryImpl() 17| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as () -> Ret 18| 1| } 19| | 20| | 21| | /** Capture a closure of expected type that can throw */ 22| 1| public func capture() -> T where T == () throws -> Ret { 23| 1| let factory = ArgumentFactoryImpl() 24| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as () throws -> Ret 25| 1| } 26| | 27| | 28| | /** Capture an argument of expected type (for dependency injection) */ 29| | func capture(argFactory: F, argStorage: ArgumentStorage) -> () -> Ret 30| 6| where F: ArgumentFactory, F.Value == T { 31| 6| 32| 6| // store instance 33| 6| let typeDescription = "\(T.self)" 34| 6| let arg = argFactory.argumentCapture(typeDescription) 35| 6| self.arg = arg 36| 6| argStorage.store(arg) 37| 6| 38| 6| return DefaultClosureHandler.it() as () -> Ret 39| 6| } 40| | 41| |} 42| | /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+OneArg.swift: 1| |// 2| |// ArgumentClosureCaptor+OneArg.swift 3| |// InstantMock iOS 4| |// 5| |// Created by Patrick on 22/07/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension that performs the actual capture for one arg */ 11| |extension ArgumentClosureCaptor { 12| | 13| | 14| | /** Capture a closure of expected type */ 15| 1| public func capture() -> T where T == (Arg1) -> Ret { 16| 1| let factory = ArgumentFactoryImpl() 17| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as (Arg1) -> Ret 18| 1| } 19| | 20| | 21| | /** Capture a closure of expected type that can throw */ 22| 1| public func capture() -> T where T == (Arg1) throws -> Ret { 23| 1| let factory = ArgumentFactoryImpl() 24| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as (Arg1) throws -> Ret 25| 1| } 26| | 27| | 28| | /** Capture an argument of expected type (for dependency injection) */ 29| | func capture(argFactory: F, argStorage: ArgumentStorage) -> (Arg1) -> Ret 30| 6| where F: ArgumentFactory, F.Value == T { 31| 6| 32| 6| // store instance 33| 6| let typeDescription = "\(T.self)" 34| 6| let arg = argFactory.argumentCapture(typeDescription) 35| 6| self.arg = arg 36| 6| argStorage.store(arg) 37| 6| 38| 6| return DefaultClosureHandler.it() as (Arg1) -> Ret 39| 6| } 40| | 41| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+ThreeArgs.swift: 1| |// 2| |// ArgumentClosureCaptor+ThreeArgs.swift 3| |// InstantMock iOS 4| |// 5| |// Created by Patrick on 22/07/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension that performs the actual capture for three args */ 11| |extension ArgumentClosureCaptor { 12| | 13| | 14| | /** Capture a closure of expected type */ 15| 1| public func capture() -> T where T == (Arg1, Arg2, Arg3) -> Ret { 16| 1| let factory = ArgumentFactoryImpl() 17| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as (Arg1, Arg2, Arg3) -> Ret 18| 1| } 19| | 20| | 21| | /** Capture a closure of expected type that can throw */ 22| 1| public func capture() -> T where T == (Arg1, Arg2, Arg3) throws -> Ret { 23| 1| let factory = ArgumentFactoryImpl() 24| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) 25| 1| as (Arg1, Arg2, Arg3) throws -> Ret 26| 1| } 27| | 28| | 29| | /** Capture an argument of expected type (for dependency injection) */ 30| | func capture(argFactory: F, argStorage: ArgumentStorage) -> (Arg1, Arg2, Arg3) -> Ret 31| 6| where F: ArgumentFactory, F.Value == T { 32| 6| 33| 6| // store instance 34| 6| let typeDescription = "\(T.self)" 35| 6| let arg = argFactory.argumentCapture(typeDescription) 36| 6| self.arg = arg 37| 6| argStorage.store(arg) 38| 6| 39| 6| return DefaultClosureHandler.it() as (Arg1, Arg2, Arg3) -> Ret 40| 6| } 41| | 42| |} 43| | 44| | /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+TwoArgs.swift: 1| |// 2| |// ArgumentClosureCaptor+TwoArgs.swift 3| |// InstantMock iOS 4| |// 5| |// Created by Patrick on 22/07/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension that performs the actual capture for two args */ 11| |extension ArgumentClosureCaptor { 12| | 13| | 14| | /** Capture an closure of expected type */ 15| 2| public func capture() -> T where T == (Arg1, Arg2) -> Ret { 16| 2| let factory = ArgumentFactoryImpl() 17| 2| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as (Arg1, Arg2) -> Ret 18| 2| } 19| | 20| | 21| | /** Capture a closure of expected type that can throw */ 22| 1| public func capture() -> T where T == (Arg1, Arg2) throws -> Ret { 23| 1| let factory = ArgumentFactoryImpl() 24| 1| return self.capture(argFactory: factory, argStorage: ArgumentStorageImpl.instance) as (Arg1, Arg2) throws -> Ret 25| 1| } 26| | 27| | 28| | /** Capture an argument of expected type (for dependency injection) */ 29| | func capture(argFactory: F, argStorage: ArgumentStorage) -> (Arg1, Arg2) -> Ret 30| 7| where F: ArgumentFactory, F.Value == T { 31| 7| 32| 7| // store instance 33| 7| let typeDescription = "\(T.self)" 34| 7| let arg = argFactory.argumentCapture(typeDescription) 35| 7| self.arg = arg 36| 7| argStorage.store(arg) 37| 7| 38| 7| return DefaultClosureHandler.it() as (Arg1, Arg2) -> Ret 39| 7| } 40| | 41| |} 42| | /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Helpers/ArgumentFactory.swift: 1| |// 2| |// ArgumentFactory.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 13/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Protocol for argument factory that aims at creating arguments */ 11| |public protocol ArgumentFactory { 12| | associatedtype Value 13| | 14| | /// Create a new argument value 15| | func argument(value: Value?) -> ArgumentValue 16| | 17| | /// Create a new any argument 18| | func argumentAny(_ typeDescription: String) -> ArgumentAny 19| | 20| | // Create a new argument closure 21| | func argumentClosure(_ typeDescription: String) -> ArgumentClosure 22| | 23| | // Create a new argument that must verify provided condition 24| | func argument(condition: @escaping (Value) -> Bool) -> ArgumentVerify 25| | func argument(condition: @escaping (Value?) -> Bool) -> ArgumentVerify 26| | 27| | // Create a new argument capture 28| | func argumentCapture(_ typeDescription: String) -> ArgumentCapture 29| |} 30| | 31| | 32| |/** Implementation of argument factory */ 33| |final class ArgumentFactoryImpl: ArgumentFactory { 34| | 35| 22| func argument(value: T?) -> ArgumentValue { 36| 22| return ArgumentValueImpl(value) 37| 22| } 38| | 39| 39| func argumentAny(_ typeDescription: String) -> ArgumentAny { 40| 39| return ArgumentAnyImpl(typeDescription) 41| 39| } 42| | 43| 9| func argumentClosure(_ typeDescription: String) -> ArgumentClosure { 44| 9| return ArgumentClosureImpl(typeDescription) 45| 9| } 46| | 47| 3| func argument(condition: @escaping (T) -> Bool) -> ArgumentVerify { 48| 3| return ArgumentVerifyMandatoryImpl(condition) 49| 3| } 50| | 51| 2| func argument(condition: @escaping (T?) -> Bool) -> ArgumentVerify { 52| 2| return ArgumentVerifyOptionalImpl(condition) 53| 2| } 54| | 55| 15| func argumentCapture(_ typeDescription: String) -> ArgumentCapture { 56| 15| return ArgumentCaptureImpl(typeDescription) 57| 15| } 58| | 59| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Helpers/ArgumentStorage.swift: 1| |// 2| |// ArgumentStorage.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 12/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Protocol for storing some arguments */ 11| |public protocol ArgumentStorage { 12| | 13| | /// Store an argument 14| | func store(_ arg: Argument) 15| | 16| | /// Get the list of all the arguments 17| | func all() -> [Argument] 18| | 19| | /// Flush any stored argument 20| | func flush() 21| | 22| |} 23| | 24| | 25| |/** Implementation for storing arguments */ 26| |final class ArgumentStorageImpl { 27| | 28| | /// Singleton 29| | static let instance = ArgumentStorageImpl() 30| | 31| | /// Actual storage array 32| | private var storage = [Argument]() 33| |} 34| | 35| | 36| |/** Extension for actually store arguments */ 37| |extension ArgumentStorageImpl: ArgumentStorage { 38| | 39| 93| func store(_ arg: Argument) { 40| 93| self.storage.append(arg) 41| 93| } 42| | 43| 77| func all() -> [Argument] { 44| 77| return self.storage 45| 77| } 46| | 47| 143| func flush() { 48| 143| self.storage.removeAll() 49| 143| } 50| | 51| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Helpers/ArgumentsConfiguration.swift: 1| |// 2| |// ArgumentsConfiguration.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 12/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Class representing a configuration of arguments */ 11| |final class ArgumentsConfiguration { 12| | 13| | /// Actual expected arguments 14| | let args: [Argument] 15| | 16| | 17| | /** Initialize with expected arguments */ 18| 135| init(_ args: [Argument]) { 19| 135| self.args = args 20| 135| } 21| | 22| |} 23| | 24| | 25| |/** Extension that returns a description of a configuration */ 26| |extension ArgumentsConfiguration: CustomStringConvertible { 27| | 28| 34| var description: String { 29| 34| var value = "" 30| 34| 31| 34| if self.args.count > 0 { 32| 35| let valuesDescriptions = self.args.map { $0.description } 33| 26| value = valuesDescriptions.joined(separator: ", ") 34| 34| } else { 35| 8| value = "none" 36| 34| } 37| 34| 38| 34| return value 39| 34| } 40| | 41| |} 42| | 43| | 44| |/** Extension that returns the number of args of any kinds */ 45| |extension ArgumentsConfiguration { 46| | 47| | /** Returns the number of arguments that must verify a certain value */ 48| 46| func numberOfArgValues() -> Int { 49| 92| return self.args.filter { $0 is ArgumentValue }.count 50| 46| } 51| | 52| | /** Returns the number of arguments that must verify a certain condition */ 53| 12| func numberOfArgVerify() -> Int { 54| 20| return self.args.filter { $0 is ArgumentVerify }.count 55| 12| } 56| | 57| |} 58| | 59| | 60| |/** Configurations are comparable depending on how the args must be verified */ 61| |extension ArgumentsConfiguration: Comparable {} 62| | 63| 8|func ==(lhs: ArgumentsConfiguration, rhs: ArgumentsConfiguration) -> Bool { 64| 8| // configurations are equal if they have the same number of args that must verify a precise value or condition 65| 8| return lhs.numberOfArgValues() == rhs.numberOfArgValues() && lhs.numberOfArgVerify() == rhs.numberOfArgVerify() 66| 8|} 67| | 68| | 69| 8|func <(lhs: ArgumentsConfiguration, rhs: ArgumentsConfiguration) -> Bool { 70| 8| // when the number of args that must verify a certain value precisely is the same, look for conditions 71| 8| if lhs.numberOfArgValues() == rhs.numberOfArgValues() { 72| 1| return lhs.numberOfArgVerify() < rhs.numberOfArgVerify() 73| 7| } 74| 7| return lhs.numberOfArgValues() < rhs.numberOfArgValues() 75| 8|} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Arguments/Helpers/ArgumentsMatcher.swift: 1| |// 2| |// ArgsMatcher.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 07/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Class designed to match some arguments against an argument configuration */ 11| |final class ArgumentsMatcher { 12| | 13| | /// Provided arguments 14| | private let args: [Any?] 15| | 16| | /** Initialize new instance with arguments and configuration */ 17| 152| init(_ args: [Any?]) { 18| 152| self.args = args 19| 152| } 20| | 21| |} 22| | 23| | 24| |/** Extension for performing the actual matching */ 25| |extension ArgumentsMatcher { 26| | 27| | 28| | /** Perform actual match */ 29| 152| func match(_ argsConfig: ArgumentsConfiguration) -> Bool { 30| 152| 31| 152| // make sure the number of arguments matches the number of expected 32| 152| if self.args.count != argsConfig.args.count { 33| 5| return false 34| 147| } 35| 147| 36| 147| // match arguments one by one 37| 147| if argsConfig.args.count > 0 { 38| 197| for i in 0...argsConfig.args.count-1 { 39| 197| let arg = args[i] 40| 197| let argConfig = argsConfig.args[i] 41| 197| 42| 197| if !argConfig.match(arg) { 43| 11| return false 44| 186| } 45| 186| } 46| 136| } 47| 136| 48| 136| return true 49| 147| } 50| | 51| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/DefaultValue/DefaultClosureHandler.swift: 1| |// 2| |// DefaultClosureHandler.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 08/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Helper that provides a simple way to create closure arguments with any argument and return value types */ 11| |final class DefaultClosureHandler { 12| | 13| | /** Provide a default closure with provided signature (no args) */ 14| 9| public static func it() -> () -> Ret { 15| 9| let closure: () -> Ret = { return () as! Ret } 16| 9| return closure 17| 9| } 18| | 19| | /** Provide a default closure with provided signature (one arg) */ 20| 9| public static func it() -> (Arg1) -> Ret { 21| 9| let closure: (Arg1) -> Ret = { _ in return () as! Ret } 22| 9| return closure 23| 9| } 24| | 25| | /** Provide a default closure with provided signature (2 args) */ 26| 13| public static func it() -> (Arg1, Arg2) -> Ret { 27| 13| let closure: (Arg1, Arg2) -> Ret = { _, _ in return () as! Ret } 28| 13| return closure 29| 13| } 30| | 31| | /** Provide a default closure with provided signature (3 args) */ 32| 9| public static func it() -> (Arg1, Arg2, Arg3) -> Ret { 33| 9| let closure: (Arg1, Arg2, Arg3) -> Ret = { _, _, _ in return () as! Ret } 34| 9| return closure 35| 9| } 36| | 37| | /** Provide a default closure with provided signature (4 args) */ 38| 9| public static func it() -> (Arg1, Arg2, Arg3, Arg4) -> Ret { 39| 9| let closure: (Arg1, Arg2, Arg3, Arg4) -> Ret = { _, _, _, _ in return () as! Ret } 40| 9| return closure 41| 9| } 42| | 43| | /** Provide a default closure with provided signature (5 args) */ 44| 9| public static func it() -> (Arg1, Arg2, Arg3, Arg4, Arg5) -> Ret { 45| 9| let closure: (Arg1, Arg2, Arg3, Arg4, Arg5) -> Ret = { _, _, _, _, _ in return () as! Ret } 46| 9| return closure 47| 9| } 48| | 49| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/DefaultValue/DefaultValueHandler.swift: 1| |// 2| |// DefaultValueHandler.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 12/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** This class is a helper that provides default values */ 11| |final class DefaultValueHandler { 12| | 13| | 14| | /** Return the default value, or nil if type is neither `MockUsable`, nor `Closure` */ 15| 189| var it: T? { 16| 189| var ret: T? 17| 189| 18| 189| // try to fetch the default value of `MockUsable` types 19| 189| if let mockUsableType = T.self as? MockUsable.Type { 20| 128| if let value = mockUsableType.anyValue as? T { 21| 128| ret = value 22| 128| } 23| 189| } 24| 189| 25| 189| return ret 26| 189| } 27| | 28| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Factories/ExpectationFactory.swift: 1| |// 2| |// ExpectationFactory.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 08/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Protocol for creating new `Expectation` instances */ 11| |public protocol ExpectationFactory { 12| | 13| | /// Create new `Expectation` instance that must be fulfilled, with provided `Stub` 14| | func expectation(withStub stub: Stub) -> Expectation 15| | 16| | /// Create new `Expectation` instantce that must be rejected, with provided `Stub` 17| | func rejection(withStub stub: Stub) -> Expectation 18| |} 19| | 20| | 21| |/** Main implementation */ 22| |public final class ExpectationFactoryImpl: ExpectationFactory { 23| | 24| | /// Singleton 25| | public static let instance = ExpectationFactoryImpl() 26| | 27| 2| public func expectation(withStub stub: Stub) -> Expectation { 28| 2| return Expectation(withStub: stub) 29| 2| } 30| | 31| 1| public func rejection(withStub stub: Stub) -> Expectation { 32| 1| return Expectation(withStub: stub, reject: true) 33| 1| } 34| | 35| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Interceptors/CallInterceptor.swift: 1| |// 2| |// CallInterceptor.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 06/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Base class for call interceptors */ 11| |public class CallInterceptor { 12| | 13| | /// Configuration for the call 14| | var configuration: CallConfiguration? 15| | 16| | 17| | /** Method is being called */ 18| | @discardableResult 19| 0| func handleCall(_ args: [Any?]) throws -> Any? { 20| 0| fatalError("[CallInterceptor] handleCall: virtual method, must be overloaded in subclasses") 21| 0| } 22| | 23| |} 24| | 25| | 26| |/** Extension for a list of interceptors */ 27| |extension Collection where Iterator.Element: CallInterceptor { 28| | 29| | /** Filter a list of interceptors if they match the provided arguments */ 30| 149| func matching(_ args: [Any?]) -> [Iterator.Element] { 31| 149| 32| 149| // create arg matcher 33| 149| let argsMatcher = ArgumentsMatcher(args) 34| 149| 35| 149| // return filtered list 36| 150| return self.filter { interceptor in 37| 150| var matching = false 38| 150| if let config = interceptor.configuration { 39| 149| matching = argsMatcher.match(config.args) 40| 150| } 41| 150| return matching 42| 150| } 43| 149| 44| 149| } 45| | 46| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Interceptors/Expectation.swift: 1| |// 2| |// Expectation.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 06/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** This class represents an expectation to be verified */ 11| |public final class Expectation: CallInterceptor { 12| | 13| | 14| | /// Expected number of calls 15| | private var expectedNumberOfCalls: Int? 16| | 17| | /// Actual number of calls 18| | private var numberOfCalls: Int = 0 19| | 20| | /// Expectation must be rejected 21| | private var reject: Bool 22| | 23| | /// Stub instance 24| | private let stub: Stub 25| | 26| | /// Assertion 27| | private let assertion: Assertion 28| | 29| | 30| | // MARK: Initializers 31| | 32| | /** Initialize with provided stub */ 33| 18| convenience init(withStub stub: Stub, reject: Bool = false) { 34| 18| self.init(withStub: stub, reject: reject, assertion: AssertionImpl.instance) 35| 18| } 36| | 37| | 38| | /** Initialize with provided stub and assertion (for dependency injection) */ 39| 80| public init(withStub stub: Stub, reject: Bool = false, assertion: Assertion) { 40| 80| self.stub = stub 41| 80| self.reject = reject 42| 80| self.assertion = assertion 43| 80| } 44| | 45| | 46| | // MARK: Call 47| | 48| | /** Method is being called */ 49| | @discardableResult 50| 74| override func handleCall(_ args: [Any?]) throws -> Any? { 51| 74| self.numberOfCalls = self.numberOfCalls + 1 52| 74| return nil // don't care about return values 53| 74| } 54| | 55| |} 56| | 57| | 58| | 59| |// MARK: Registration 60| |extension Expectation { 61| | 62| | /** register call */ 63| | @discardableResult 64| 64| public func call(_ value: T, count: Int? = nil) -> Stub { 65| 64| self.expectedNumberOfCalls = count 66| 64| return self.stub 67| 64| } 68| | 69| |} 70| | 71| | 72| |// MARK: Verification 73| |extension Expectation { 74| | 75| | 76| | /// Flag indicating if the expectation was verified 77| 131| var verified: Bool { 78| 131| if let expected = self.expectedNumberOfCalls { 79| 16| return self.numberOfCalls == expected 80| 115| } 81| 115| return self.numberOfCalls > 0 82| 131| } 83| | 84| | 85| | /// Reason for a failure, nil if expectation verified 86| 39| var reason: String? { 87| 39| if self.reject { 88| 9| return self.rejectedReason 89| 30| } 90| 30| return self.acceptedReason 91| 39| } 92| | 93| | 94| | /// Reason for an unfulfilled expectation 95| 30| private var acceptedReason: String? { 96| 30| var value: String? 97| 30| 98| 30| if !self.verified, let configuration = self.configuration { 99| 26| var details = configuration.function + " " 100| 26| 101| 26| if let expected = self.expectedNumberOfCalls { 102| 3| details = details + "not called the expected number of times (\(self.numberOfCalls) out of \(expected))" 103| 26| } else { 104| 23| details = details + "never called" 105| 26| } 106| 26| 107| 26| details = details + " with expected args (\(configuration.args))" 108| 26| value = details 109| 30| } 110| 30| 111| 30| return value 112| 30| } 113| | 114| | 115| | /// Reason for an expectation that should have been rejected 116| 9| private var rejectedReason: String? { 117| 9| var value: String? 118| 9| 119| 9| if self.verified, let configuration = self.configuration { 120| 5| var details = configuration.function + " " 121| 5| 122| 5| if let expected = self.expectedNumberOfCalls { 123| 2| details = details + "called a wrong number of times (\(expected))" 124| 5| } else { 125| 3| details = details + "called" 126| 5| } 127| 5| 128| 5| details = details + " with unexpected args (\(configuration.args))" 129| 5| value = details 130| 9| } 131| 9| 132| 9| return value 133| 9| } 134| | 135| | 136| | /** Verify current expectation */ 137| 87| func verify(file: StaticString?, line: UInt?) { 138| 87| let success = (!self.reject && self.verified) || (self.reject && !self.verified) 139| 87| 140| 87| if success { 141| 60| self.assertion.success(file: file, line: line) 142| 87| } else { 143| 27| self.assertion.fail(self.reason, file: file, line: line) 144| 87| } 145| 87| } 146| | 147| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Interceptors/Helpers/CallConfiguration.swift: 1| |// 2| |// CallConfiguration.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 08/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Class representing the configuration of a call */ 11| |final class CallConfiguration { 12| | 13| | /// Function called 14| | let function: String 15| | 16| | /// Arguments configuration 17| | let args: ArgumentsConfiguration 18| | 19| | 20| | /** Initialize with function and args configuration */ 21| 153| init(for function: String, with args: ArgumentsConfiguration) { 22| 153| self.function = function 23| 153| self.args = args 24| 153| } 25| | 26| |} 27| | 28| | 29| |/** Two configurations are comparable, in terms of arguments */ 30| |extension CallConfiguration: Comparable {} 31| | 32| 2|func ==(lhs: CallConfiguration, rhs: CallConfiguration) -> Bool { 33| 2| return lhs.args == rhs.args 34| 2|} 35| | 36| 4|func <(lhs: CallConfiguration, rhs: CallConfiguration) -> Bool { 37| 4| return lhs.args < rhs.args 38| 4|} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Interceptors/Helpers/CallInterceptorStorage.swift: 1| |// 2| |// CallInterceptorStorage.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 06/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Class responsible for storing call interceptors */ 11| |final class CallInterceptorStorage { 12| | 13| | 14| | /** Storing dictionary */ 15| | private var repository = [String: [T]]() 16| | 17| | 18| | /** 19| | Register an interceptor 20| | - parameter interceptor: call interceptor to register 21| | - parameter function: function name triggering this interceptor 22| | - parameter args: list of arguments passed to the function for this interceptor 23| | */ 24| 138| func store(interceptor: T, for function: String) { 25| 138| var interceptors = self.repository[function] ?? [T]() 26| 138| interceptors.append(interceptor) 27| 138| self.repository[function] = interceptors 28| 138| } 29| | 30| | 31| | /** 32| | Return the list of interceptors for the given function 33| | - parameter function: function name for retrieving interceptors 34| | - returns: list of interceptors 35| | */ 36| 149| func interceptors(for function: String) -> [T] { 37| 149| return self.repository[function] ?? [T]() 38| 149| } 39| | 40| | 41| | /** Return the list of all the interceptors */ 42| 86| func all() -> [T] { 43| 86| return self.repository.values.flatMap { (values: [T]) -> [T] in 44| 85| return values 45| 85| } 46| 86| } 47| | 48| | /** Invalidates repository */ 49| 5| func removeAll() { 50| 5| self.repository.removeAll() 51| 5| } 52| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Interceptors/Stub.swift: 1| |// 2| |// Stub.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 06/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** This class represents a stub */ 11| |public final class Stub: CallInterceptor { 12| | 13| | /// Flag indicating that a return value is expected 14| | private var hasReturnValue = false 15| | 16| | /// The actual return value 17| | private var returnValue: Any? 18| | 19| | /// Closure determining the return value 20| | private var returnValueClosure: ((_ args: [Any?]) -> Any?)? 21| | 22| | /// Closure to be called before returning 23| | private var closure: ((_ args: [Any?]) -> Void)? 24| | 25| | /// Error to be thrown 26| | private var error: Error? 27| | 28| | /// Flag indicating that the stub is configured to return something 29| 70| var returns: Bool { 30| 70| return self.hasReturnValue || self.returnValueClosure != nil 31| 70| } 32| | 33| | 34| | // MARK: Call 35| | 36| | /** Method is being called */ 37| | @discardableResult 38| 78| override func handleCall(_ args: [Any?]) throws -> Any? { 39| 78| var ret: Any? 40| 78| 41| 78| // capture args 42| 78| if let configuration = self.configuration { 43| 70| self.capture(args, configArgs: configuration.args) 44| 78| } 45| 78| 46| 78| // call closure if required 47| 78| if let closure = self.closure { closure(args) } 48| 78| 49| 78| // throw error if required 50| 78| if let error = self.error { 51| 3| throw error 52| 75| } 53| 75| 54| 75| // return value if one specified 55| 75| if self.hasReturnValue { 56| 10| ret = self.returnValue 57| 75| } 58| 75| // otherwise, compute from closure 59| 75| else if let returnValueClosure = self.returnValueClosure { 60| 4| ret = returnValueClosure(args) 61| 75| } 62| 75| 63| 75| return ret 64| 75| } 65| | 66| | 67| | /** Capture arguments */ 68| 70| private func capture(_ args: [Any?], configArgs: ArgumentsConfiguration) { 69| 70| guard args.count > 0 else { return } 70| 65| 71| 92| for i in 0...args.count-1 { 72| 92| let arg = args[i] 73| 92| let configArg = configArgs.args[i] 74| 92| 75| 92| if let config = configArg as? ArgumentCapture { 76| 18| config.setValue(arg) 77| 92| } 78| 92| } 79| 65| } 80| | 81| |} 82| | 83| | 84| | 85| |// MARK: Registration 86| |extension Stub { 87| | 88| | /** register call */ 89| | @discardableResult 90| 8| public func call(_ value: T) -> Stub { 91| 8| // nothing to do 92| 8| return self 93| 8| } 94| | 95| |} 96| | 97| | 98| | 99| |// MARK: Actions 100| |extension Stub { 101| | 102| | 103| | /** Register return value */ 104| | @discardableResult 105| 13| public func andReturn(_ value: Any?) -> Stub { 106| 13| self.returnValue = value 107| 13| self.hasReturnValue = true 108| 13| return self 109| 13| } 110| | 111| | 112| | /** Register return value closure */ 113| | @discardableResult 114| 5| public func andReturn(closure: @escaping (_ args: [Any?]) -> Any?) -> Stub { 115| 5| self.returnValueClosure = closure 116| 5| return self 117| 5| } 118| | 119| | 120| | /** Register closure to be called at the end */ 121| | @discardableResult 122| 5| public func andDo(_ closure: @escaping (_ args: [Any?]) -> Void) -> Stub { 123| 5| self.closure = closure 124| 5| return self 125| 5| } 126| | 127| | 128| | /** Register error to be thrown */ 129| | @discardableResult 130| 3| public func andThrow(_ error: Error) -> Stub { 131| 3| self.error = error 132| 3| return self 133| 3| } 134| | 135| |} 136| | 137| | 138| |/** Extension for a list of stubs */ 139| |extension Collection where Iterator.Element: Stub { 140| | 141| | 142| | /** Return the best stub (the most precise one) */ 143| 76| func best() -> Stub? { 144| 76| return self.sorted().first 145| 76| } 146| | 147| | 148| | /** Return list of stubs sorted by precision */ 149| 76| private func sorted() -> [Stub] { 150| 76| return self.sorted(by: { (stub1, stub2) -> Bool in 151| 2| return stub2 < stub1 152| 2| }) 153| 76| } 154| | 155| |} 156| | 157| | 158| |/** Two stubs are comparable, in terms of argument configuration */ 159| |extension Stub: Comparable {} 160| | 161| | 162| 2|public func ==(lhs: Stub, rhs: Stub) -> Bool { 163| 2| if let configuration1 = lhs.configuration, let configuration2 = rhs.configuration { 164| 1| return configuration1 == configuration2 165| 1| } 166| 1| return false 167| 2|} 168| | 169| | 170| 4|public func <(lhs: Stub, rhs: Stub) -> Bool { 171| 4| if let configuration1 = lhs.configuration, let configuration2 = rhs.configuration { 172| 3| return configuration1 < configuration2 173| 3| } 174| 1| return false 175| 4|} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Mock.swift: 1| |// 2| |// Mock.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 06/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Main protocol for adding mocking capabilities to any object, using delegation */ 11| |public protocol MockDelegate { 12| | 13| | /// Provide mock instance 14| | var it: Mock { get } 15| |} 16| | 17| | 18| |/** Protocol for mock expectations */ 19| |public protocol MockExpectation: MockExpectationFactory { 20| | 21| | /// Verify all expections on the current instance 22| | func verify(file: StaticString?, line: UInt?) 23| |} 24| | 25| | 26| |/** Protocol for the creation of mock expectations */ 27| |public protocol MockExpectationFactory { 28| | 29| | /// Create new expectation for current instance 30| | func expect() -> Expectation 31| | func reject() -> Expectation 32| |} 33| | 34| | 35| |/** Protocol for stubs */ 36| |public protocol MockStub { 37| | 38| | /// Create new stub for current instance 39| | func stub() -> Stub 40| |} 41| | 42| | 43| |/** 44| | A `Mock` instance is dedicated to being used in unit tests, in order to mock some specific behaviors. 45| | It can be used in two particular cases: 46| | - **verify** some behaviors with **expectations** (represented by the `Expectation` class) 47| | - **stub** behaviors, to return or perform some actions under certain conditions (stubs are represented by the 48| | `Stub` class) 49| | 50| | Example of an expectation being verified: 51| | 52| | let mock: Mock 53| | mock.expect().call(mock.someMethod()) 54| | mock.verify() 55| | 56| | Example of a stub: 57| | 58| | let mock: Mock 59| | mock.stub().call(mock.someMethod()).andReturn(someValue) 60| | 61| | */ 62| |open class Mock { 63| | 64| | // interceptors defined in registration mode 65| | private var expectationBeingRegistered: Expectation? 66| | private var stubBeingRegistered: Stub? 67| | 68| | // interceptors storage 69| | private let expectationStorage = CallInterceptorStorage() 70| | private let stubStorage = CallInterceptorStorage() 71| | 72| | // interceptors factories 73| | private let expectationFactory: ExpectationFactory 74| | 75| | // deferring registration for property mocking 76| | private var deferCallRegistration = false 77| | var deferredFunction: String? 78| | 79| | // property needed to be mocked 80| 3| public var property: Property { 81| 3| self.deferCallRegistration = true 82| 3| return Property(mock: self) 83| 3| } 84| | 85| | 86| | // MARK: Initializers 87| | 88| | /** Initialize instance with optional provided `ExpectationFactory` for dependency injection */ 89| 67| public init(_ expectationFactory: ExpectationFactory = ExpectationFactoryImpl.instance) { 90| 67| self.expectationFactory = expectationFactory 91| 67| } 92| | 93| | 94| | // MARK: Methods 95| | /** Resets all expectations and rejects */ 96| 2| public func resetExpectations() { 97| 2| self.expectationBeingRegistered = nil 98| 2| self.expectationStorage.removeAll() 99| 2| } 100| | 101| | /** Resets all stubs */ 102| 2| public func resetStubs() { 103| 2| self.stubBeingRegistered = nil 104| 2| self.stubStorage.removeAll() 105| 2| } 106| | 107| |} 108| | 109| | 110| | 111| |/* Extension for handling the creation of mock expectations */ 112| |extension Mock: MockExpectationFactory { 113| | 114| | @discardableResult 115| 58| public func expect() -> Expectation { 116| 58| 117| 58| // flush all the argument configurations from the storage 118| 58| ArgumentStorageImpl.instance.flush() 119| 58| 120| 58| let stub = Stub() 121| 58| let expectation = self.expectationFactory.expectation(withStub: stub) 122| 58| 123| 58| // mark instances as being ready for registration 124| 58| self.expectationBeingRegistered = expectation 125| 58| self.stubBeingRegistered = stub 126| 58| 127| 58| return expectation 128| 58| } 129| | 130| | 131| | @discardableResult 132| 3| public func reject() -> Expectation { 133| 3| 134| 3| // flush all the argument configurations from the storage 135| 3| ArgumentStorageImpl.instance.flush() 136| 3| 137| 3| let stub = Stub() 138| 3| let rejection = self.expectationFactory.rejection(withStub: stub) 139| 3| 140| 3| // mark instances as being ready for registration 141| 3| self.expectationBeingRegistered = rejection 142| 3| self.stubBeingRegistered = stub 143| 3| 144| 3| return rejection 145| 3| } 146| | 147| |} 148| | 149| | 150| |/* Extension for handling mock expectations */ 151| |extension Mock { 152| | 153| | /** 154| | Verify that all expectations are ok 155| | - parameter file: optional string for the name of the file being verified, default takes caller file name 156| | - parameter line: optional line for the line of the file being verified, default takes caller file line 157| | */ 158| 83| public func verify(file: StaticString? = #file, line: UInt? = #line) { 159| 85| for expectation in self.expectationStorage.all() { 160| 85| expectation.verify(file: file, line: line) 161| 85| } 162| 83| } 163| | 164| | 165| | /** 166| | Register an expectation 167| | - parameter expectation: expectation to be registered 168| | - parameter function: function for which expectations must be handled 169| | - parameter argsConfig: arguments configuration passed to the function being regsitered 170| | */ 171| 61| private func register(expectation: Expectation, for function: String, with argsConfig: ArgumentsConfiguration) { 172| 61| 173| 61| // compute configurations based on provided args 174| 61| let configuration = CallConfiguration(for: function, with: argsConfig) 175| 61| expectation.configuration = configuration 176| 61| 177| 61| // store the expectation for function 178| 61| self.expectationStorage.store(interceptor: expectation, for: function) 179| 61| 180| 61| // reset registration mode 181| 61| self.expectationBeingRegistered = nil 182| 61| } 183| | 184| | 185| | /** 186| | Handle expectations while mock is being called 187| | - parameter function: function being called 188| | - parameter args: list of arguments passed to the function being called 189| | */ 190| 73| private func handleExpectationsWhileBeingCalled(for function: String, with args: [Any?]) { 191| 73| 192| 73| // retrieve expectations for the function 193| 73| let expectations = self.expectationStorage.interceptors(for: function) 194| 73| 195| 73| // notify expectations matching args that they are fullfilled 196| 73| for expectation in expectations.matching(args) { 197| 61| do { 198| 61| try expectation.handleCall(args) 199| 61| } catch { 200| 0| fatalError("Expectation threw unexpected error=\(error)") 201| 61| } 202| 73| } 203| 73| 204| 73| } 205| | 206| |} 207| | 208| | 209| |/* Extension for handling stubs */ 210| |extension Mock: MockStub { 211| | 212| | @discardableResult 213| 8| public func stub() -> Stub { 214| 8| let stub = Stub() 215| 8| 216| 8| // flush all the argument configurations from the storage 217| 8| ArgumentStorageImpl.instance.flush() 218| 8| 219| 8| // mark instance as being ready for registration 220| 8| self.stubBeingRegistered = stub 221| 8| 222| 8| return stub 223| 8| } 224| | 225| | 226| | /** 227| | Register a stub 228| | - parameter stub: stub to be registered 229| | - parameter function: function for which stubs must be handled 230| | - parameter argsConfig: arguments configuration passed to the function being regsitered 231| | */ 232| 69| private func register(stub: Stub, for function: String, with argsConfig: ArgumentsConfiguration) { 233| 69| 234| 69| // compute configurations based on provided args 235| 69| let configuration = CallConfiguration(for: function, with: argsConfig) 236| 69| stub.configuration = configuration 237| 69| 238| 69| // store the stub for function 239| 69| self.stubStorage.store(interceptor: stub, for: function) 240| 69| 241| 69| // reset registration mode 242| 69| self.stubBeingRegistered = nil 243| 69| } 244| | 245| | 246| | /** 247| | Handle stubs while mock is being called 248| | - parameter function: function being called 249| | - parameter args: list of arguments passed to the function being called 250| | */ 251| 73| private func handleStubsWhileBeingCalled(for function: String, with args: [Any?]) throws -> (T?, Bool) { 252| 73| var ret: T? 253| 73| var useDefaultValue = true 254| 73| 255| 73| // retrieve configured stubs for the function 256| 73| let stubs = self.stubStorage.interceptors(for: function) 257| 73| 258| 73| // find the best stub and apply it 259| 73| if let stub = stubs.matching(args).best() { 260| 69| let retVal = try stub.handleCall(args) 261| 69| if retVal is T? { 262| 67| ret = retVal as? T 263| 69| } else { 264| 2| fatalError("Unexpected type of return value \(T.self)") 265| 69| } 266| 69| if stub.returns { useDefaultValue = false } 267| 73| } 268| 73| 269| 73| return (ret, useDefaultValue) 270| 73| } 271| | 272| |} 273| | 274| | 275| |/** Extension for handling calls to the mock */ 276| |extension Mock { 277| | 278| | /** Call with no return value */ 279| 54| public func call(_ args: Any?..., function: String = #function) { 280| 54| let ret: Void? = try? self.doCall(args, function: function) 281| 54| return ret ?? () 282| 54| } 283| | 284| | 285| | /** Call with return type object */ 286| 82| public func call(_ args: Any?..., function: String = #function) -> T? { 287| 82| return try? self.doCall(args, function: function) as T? 288| 82| } 289| | 290| | 291| | /** Throwing call with no return value */ 292| 2| public func callThrowing(_ args: Any?..., function: String = #function) throws { 293| 2| let ret: Void? = try self.doCall(args, function: function) 294| 2| return ret ?? () 295| 2| } 296| | 297| | 298| | /** Throwing call with return type object */ 299| 4| public func callThrowing(_ args: Any?..., function: String = #function) throws -> T? { 300| 4| return try self.doCall(args, function: function) as T? 301| 4| } 302| | 303| | 304| | /** Handle a call */ 305| | @discardableResult 306| 142| private func doCall(_ args: [Any?], function: String) throws -> T? { 307| 142| var ret: T? 308| 142| 309| 142| if self.expectationBeingRegistered != nil || self.stubBeingRegistered != nil { 310| 69| ret = self.handleRegistration(of: function, with: args) 311| 142| } else { 312| 73| ret = try self.handleCall(of: function, with: args) 313| 142| } 314| 142| 315| 142| return ret 316| 142| } 317| | 318| | 319| | /** 320| | Handle the registration 321| | - parameter function: function being registered 322| | - parameter args: args for the function being registered 323| | - returns: return value for that function 324| | */ 325| 72| func handleRegistration(of function: String, with args: [Any?]) -> T? { 326| 72| 327| 72| // create a new arguments configuration 328| 72| let argsConfig = ArgumentsConfiguration(ArgumentStorageImpl.instance.all()) 329| 72| 330| 72| // make sure the number of arguments passed matches the number of configured 331| 72| if argsConfig.args.count != args.count { 332| 0| fatalError("Invalid argument configuration, see Arg class for more information") 333| 72| } 334| 72| 335| 72| // once args have been verified, flush the storage as no longer useful 336| 72| ArgumentStorageImpl.instance.flush() 337| 72| 338| 72| // perform actual registration 339| 72| let ret: T? = self.register(function, with: argsConfig) 340| 72| return ret 341| 72| } 342| | 343| | 344| | /** 345| | Register function 346| | - parameter function: function being registered 347| | - parameter argsConfig: arguments configuration passed to the function being regsitered 348| | - returns: return value for that function 349| | */ 350| 72| private func register(_ function: String, with argsConfig: ArgumentsConfiguration) -> T? { 351| 72| var ret: T? 352| 72| 353| 72| // defer registration (for setter mocking) 354| 72| if self.deferCallRegistration { 355| 3| self.deferredFunction = function 356| 3| self.deferCallRegistration = false 357| 72| } 358| 72| // or register immediately 359| 72| else { 360| 69| self.doRegister(function, with: argsConfig) 361| 72| } 362| 72| 363| 72| // default value 364| 72| if let value = DefaultValueHandler().it { 365| 41| ret = value 366| 72| } 367| 72| 368| 72| return ret 369| 72| } 370| | 371| | 372| | /** 373| | Performs the actual registration of a function 374| | - parameter function: function being registered 375| | - parameter argsConfig: arguments configuration passed to the function being regsitered 376| | - returns: return value for that function 377| | */ 378| 69| private func doRegister(_ function: String, with argsConfig: ArgumentsConfiguration) { 379| 69| // register expectation if necessary 380| 69| if let expectation = self.expectationBeingRegistered { 381| 61| self.register(expectation: expectation, for: function, with: argsConfig) 382| 69| } 383| 69| 384| 69| // register stub if necessary 385| 69| if let stub = self.stubBeingRegistered { 386| 69| self.register(stub: stub, for: function, with: argsConfig) 387| 69| } 388| 69| } 389| | 390| | 391| | /** 392| | Handle actual call to the function 393| | - parameter function: function being called 394| | - parameter args: arguments of the function 395| | - returns: return value for that function 396| | */ 397| 73| private func handleCall(of function: String, with args: [Any?]) throws -> T? { 398| 73| var ret: T? 399| 73| var useDefaultValue = true 400| 73| 401| 73| // notify interceptors they are being called 402| 73| self.handleExpectationsWhileBeingCalled(for: function, with: args) 403| 73| (ret, useDefaultValue) = try self.handleStubsWhileBeingCalled(for: function, with: args) 404| 73| 405| 73| // default value 406| 73| if useDefaultValue, let value = DefaultValueHandler().it { 407| 33| ret = value 408| 73| } 409| 73| 410| 73| return ret 411| 73| } 412| | 413| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/MockUsable/Array+MockUsable.swift: 1| |// 2| |// Array+MockUsable.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 08/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension for making `Array` easily usage in mocks */ 11| |extension Array: MockUsable { 12| | 13| 3| public static var any: Array { 14| 3| return Array() 15| 3| } 16| | 17| 3| public static var anyValue: MockUsable { 18| 3| return Array.any 19| 3| } 20| | 21| 4| public func equal(to value: MockUsable?) -> Bool { 22| 4| guard let arrayValue = value as? Array else { return false } 23| 2| return VerifierImpl.instance.equalArray(self, to: arrayValue) 24| 4| } 25| | 26| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/MockUsable/Bool+MockUsable.swift: 1| |// 2| |// Bool+MockUsable.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 06/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension for making `Bool` easily usage in mocks */ 11| |extension Bool: MockUsable { 12| | 13| | public static let any = false 14| | 15| 3| public static var anyValue: MockUsable { 16| 3| return Bool.any 17| 3| } 18| | 19| 4| public func equal(to value: MockUsable?) -> Bool { 20| 4| guard let boolValue = value as? Bool else { return false } 21| 2| return self == boolValue 22| 4| } 23| | 24| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/MockUsable/Date+MockUsable.swift: 1| |// 2| |// Date+MockUsable.swift 3| |// InstantMock 4| |// 5| |// Created by Arnaud Barisain-Monrose on 22/04/2020. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| |import Foundation 10| | 11| |/** Extension for making `Date` easily usage in mocks */ 12| |extension Date: MockUsable { 13| | 14| | public static let any = Date(timeIntervalSince1970: 1577836801) 15| | 16| 3| public static var anyValue: MockUsable { 17| 3| return Date.any 18| 3| } 19| | 20| 4| public func equal(to value: MockUsable?) -> Bool { 21| 4| guard let dateValue = value as? Date else { return false } 22| 2| return self == dateValue 23| 4| } 24| | 25| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/MockUsable/Dictionary+MockUsable.swift: 1| |// 2| |// Dictionary+MockUsable.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 08/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension for making `Dictionary` easily usage in mocks */ 11| |extension Dictionary: MockUsable { 12| | 13| 3| public static var any: Dictionary { 14| 3| return Dictionary() 15| 3| } 16| | 17| 3| public static var anyValue: MockUsable { 18| 3| return Dictionary.any 19| 3| } 20| | 21| 6| public func equal(to value: MockUsable?) -> Bool { 22| 6| guard let dictValue = value as? Dictionary else { return false } 23| 4| 24| 4| // sort keys and compare them 25| 4| let dictValueKeys = dictValue.keys.sorted { key1, key2 -> Bool in 26| 1| return key1.hashValue < key2.hashValue 27| 1| } 28| 4| let keys = self.keys.sorted { key1, key2 -> Bool in 29| 1| return key1.hashValue < key2.hashValue 30| 1| } 31| 4| if !VerifierImpl.instance.equalArray(keys, to: dictValueKeys) { 32| 1| return false 33| 3| } 34| 3| 35| 3| // compare values 36| 4| for key in keys { 37| 4| if !VerifierImpl.instance.equal(self[key], to: dictValue[key]) { 38| 1| return false 39| 3| } 40| 3| } 41| 2| 42| 2| return true 43| 3| } 44| | 45| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/MockUsable/Double+MockUsable.swift: 1| |// 2| |// Double+MockUsable.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 06/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension for making `Double` easily usage in mocks */ 11| |extension Double: MockUsable { 12| | 13| | public static let any = 42.0 14| | 15| 3| public static var anyValue: MockUsable { 16| 3| return Double.any 17| 3| } 18| | 19| 4| public func equal(to value: MockUsable?) -> Bool { 20| 4| guard let doubleValue = value as? Double else { return false } 21| 2| return self == doubleValue 22| 4| } 23| | 24| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/MockUsable/Float+MockUsable.swift: 1| |// 2| |// Float+MockUsable.swift 3| |// InstantMock 4| |// 5| |// Created by Arnaud Barisain-Monrose on 21/04/2020. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension for making `Float` easily usage in mocks */ 11| |extension Float: MockUsable { 12| | 13| | public static let any = 42.0 as Float 14| | 15| 3| public static var anyValue: MockUsable { 16| 3| return Float.any 17| 3| } 18| | 19| 5| public func equal(to value: MockUsable?) -> Bool { 20| 5| guard let doubleValue = value as? Float else { return false } 21| 3| return self == doubleValue 22| 5| } 23| | 24| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/MockUsable/Int+MockUsable.swift: 1| |// 2| |// Int+MockUsable.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 06/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| |/** Extension for making `Int` easily usage in mocks */ 10| |extension FixedWidthInteger where Self: MockUsable { 11| | 12| 26| public func equal(to value: MockUsable?) -> Bool { 13| 26| guard let intValue = value as? Self else { return false } 14| 24| return self == intValue 15| 26| } 16| | 17| |} 18| | 19| |extension Int: MockUsable { 20| | public static let any = 42 21| | 22| 24| public static var anyValue: MockUsable { 23| 24| return Int.any 24| 24| } 25| |} 26| |extension Int64: MockUsable { 27| | public static let any = 42 as Int64 28| | 29| 3| public static var anyValue: MockUsable { 30| 3| return Int64.any 31| 3| } 32| |} 33| |extension UInt: MockUsable { 34| | public static let any = 42 as UInt 35| | 36| 3| public static var anyValue: MockUsable { 37| 3| return UInt.any 38| 3| } 39| |} 40| |extension UInt64: MockUsable { 41| | public static let any = 42 as UInt64 42| | 43| 3| public static var anyValue: MockUsable { 44| 3| return UInt64.any 45| 3| } 46| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/MockUsable/Set+MockUsable.swift: 1| |// 2| |// Set+MockUsable.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 08/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension for making `Set` easily usage in mocks */ 11| |extension Set: MockUsable { 12| | 13| 3| public static var any: Set { 14| 3| return Set() 15| 3| } 16| | 17| 3| public static var anyValue: MockUsable { 18| 3| return Set.any 19| 3| } 20| | 21| 4| public func equal(to value: MockUsable?) -> Bool { 22| 4| guard let setValue = value as? Set else { return false } 23| 2| return self == setValue 24| 4| } 25| | 26| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/MockUsable/String+MockUsable.swift: 1| |// 2| |// String+MockUsable.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 06/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Extension for making `String` easily usage in mocks */ 11| |extension String: MockUsable { 12| | 13| | public static let any = "anyStringValue" 14| | 15| 74| public static var anyValue: MockUsable { 16| 74| return String.any 17| 74| } 18| | 19| 59| public func equal(to value: MockUsable?) -> Bool { 20| 59| guard let stringValue = value as? String else { return false } 21| 57| return self == stringValue 22| 59| } 23| | 24| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Property/Property.swift: 1| |// 2| |// Property.swift 3| |// InstantMock iOS 4| |// 5| |// Created by Patrick on 03/03/2018. 6| |// Copyright © 2018 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Represents a property to be mocked */ 11| |public final class Property { 12| | 13| | /// mock dependency 14| | private weak var mock: Mock? 15| | 16| | 17| | /// Initializers 18| 3| init(mock: Mock) { 19| 3| self.mock = mock 20| 3| } 21| | 22| | 23| | /** Register a mocked setter */ 24| 3| public func set(_ prop: T, value: T) { 25| 3| if let function = self.mock?.deferredFunction { 26| 3| self.mock?.handleRegistration(of: function, with: [value]) as Void? 27| 3| } 28| 3| } 29| | 30| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Verifications/Assertion.swift: 1| |// 2| |// Assertion.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 08/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| |import XCTest 10| | 11| | 12| |/** Protocol for an Assertion */ 13| |public protocol Assertion { 14| | 15| | /** 16| | Successful assertion 17| | - parameter file: file where the failure occured 18| | - parameter line: line in the file where the failure occured 19| | */ 20| | func success(file: StaticString?, line: UInt?) 21| | 22| | /** 23| | Failed assertion 24| | - parameter description: description of the failure 25| | - parameter file: file where the failure occured 26| | - parameter line: line in the file where the failure occured 27| | */ 28| | func fail(_ description: String?, file: StaticString?, line: UInt?) 29| |} 30| | 31| | 32| |/** Standard implementation of an Assertion */ 33| |final class AssertionImpl: Assertion { 34| | 35| | /// Singleton 36| | static let instance = AssertionImpl() 37| | 38| | 39| 0| func success(file: StaticString?, line: UInt?) { 40| 0| // nothing to do 41| 0| } 42| | 43| | 44| 0| func fail(_ description: String?, file: StaticString?, line: UInt?) { 45| 0| 46| 0| let message = description ?? "" 47| 0| if let file = file, let line = line { 48| 0| XCTFail(message, file: file, line: line) 49| 0| } else { 50| 0| XCTFail(message) 51| 0| } 52| 0| 53| 0| } 54| | 55| |} /Users/travis/build/pirishd/InstantMock/Sources/InstantMock/Verifications/Verifier.swift: 1| |// 2| |// Verifier.swift 3| |// InstantMock 4| |// 5| |// Created by Patrick on 08/05/2017. 6| |// Copyright © 2017 pirishd. All rights reserved. 7| |// 8| | 9| | 10| |/** Protoocl dedicated to verify equality between values */ 11| |public protocol Verifier { 12| | func equal(_ arg: Any?, to value: Any?) -> Bool 13| |} 14| | 15| | 16| |/** Main verifier implementation */ 17| |final class VerifierImpl: Verifier { 18| | 19| | 20| | /// Singleton 21| | static let instance = VerifierImpl() 22| | 23| | 24| | /** 25| | Make sure two optional values are equal 26| | - parameter arg: first argument 27| | - paramater value: second argument 28| | - returs: true if two values are equal 29| | */ 30| 81| func equal(_ arg: Any?, to value: Any?) -> Bool { 31| 81| 32| 81| // compare nil values 33| 81| if arg == nil && value == nil { return true } 34| 78| if arg != nil && value == nil { return false } 35| 77| if arg == nil && value != nil { return false } 36| 76| 37| 76| // otherwise, perform advanced verifications 38| 76| return self.equal(arg!, to: value!) 39| 77| } 40| | 41| | 42| | /** 43| | Make sure two non-nil values are equal 44| | - parameter arg: first argument 45| | - paramater value: second argument 46| | - returs: true if two values are equal 47| | */ 48| 96| func equal(_ arg: Any, to value: Any) -> Bool { 49| 96| 50| 96| // MockUsable values 51| 96| if let mockArg = arg as? MockUsable, let mockValue = value as? MockUsable { 52| 76| return mockArg.equal(to: mockValue) 53| 76| } 54| 20| 55| 20| // try to compare by reference 56| 20| if (arg as AnyObject) === (value as AnyObject) { 57| 3| return true 58| 17| } 59| 17| 60| 17| // compare Void types 61| 17| if arg is Void && value is Void { 62| 1| return true 63| 16| } 64| 16| 65| 16| // arguments can be types 66| 16| if let argType = arg as? Any.Type, let valueType = value as? Any.Type { 67| 4| return argType == valueType 68| 12| } 69| 12| 70| 12| // arguments can be tuples 71| 12| if self.equalTuples(arg, to: value) { 72| 6| return true 73| 6| } 74| 6| 75| 6| // default case 76| 6| return false 77| 12| } 78| | 79| | 80| | /** 81| | Make sure two values that are tuples are equal (up to five arguments in the tuple) 82| | - parameter arg: first argument 83| | - paramater value: second argument 84| | - returs: true if two values are equal 85| | */ 86| 12| private func equalTuples(_ arg: Any?, to value: Any?) -> Bool { 87| 12| return self.equalTuple2(arg, to: value) || self.equalTuple3(arg, to: value) 88| 12| || self.equalTuple4(arg, to: value) || self.equalTuple5(arg, to: value) 89| 12| } 90| | 91| | 92| 12| private func equalTuple2(_ arg: Any?, to value: Any?) -> Bool { 93| 12| if let (arg1, arg2) = arg as? (Any?, Any?), let (val1, val2) = value as? (Any?, Any?) { 94| 3| return self.equal(arg1, to: val1) && self.equal(arg2, to: val2) 95| 9| } 96| 9| return false 97| 12| } 98| | 99| | 100| 9| private func equalTuple3(_ arg: Any?, to value: Any?) -> Bool { 101| 9| if let (arg1, arg2, arg3) = arg as? (Any?, Any?, Any?), let (val1, val2, val3) = value as? (Any?, Any?, Any?) { 102| 2| return self.equal(arg1, to: val1) && self.equal(arg2, to: val2) && self.equal(arg3, to: val3) 103| 7| } 104| 7| return false 105| 9| } 106| | 107| | 108| 8| private func equalTuple4(_ arg: Any?, to value: Any?) -> Bool { 109| 8| if let (arg1, arg2, arg3, arg4) = arg as? (Any?, Any?, Any?, Any?), 110| 8| let (val1, val2, val3, val4) = value as? (Any?, Any?, Any?, Any?) { 111| 1| return self.equal(arg1, to: val1) && self.equal(arg2, to: val2) 112| 1| && self.equal(arg3, to: val3) && self.equal(arg4, to: val4) 113| 7| } 114| 7| return false 115| 8| } 116| | 117| | 118| 7| private func equalTuple5(_ arg: Any?, to value: Any?) -> Bool { 119| 7| if let (arg1, arg2, arg3, arg4, arg5) = arg as? (Any?, Any?, Any?, Any?, Any?), 120| 7| let (val1, val2, val3, val4, val5) = value as? (Any?, Any?, Any?, Any?, Any?) { 121| 1| return self.equal(arg1, to: val1) && self.equal(arg2, to: val2) 122| 1| && self.equal(arg3, to: val3) && self.equal(arg4, to: val4) && self.equal(arg5, to: val5) 123| 6| } 124| 6| return false 125| 7| } 126| | 127| | 128| | /** 129| | Make sure two arrays are equal 130| | - parameter arg: first argument 131| | - paramater value: second argument 132| | - returs: true if two values are equal 133| | */ 134| 9| func equalArray(_ arg: [Any?], to value: [Any?]) -> Bool { 135| 9| 136| 9| // make sure the two arrays have the same number of elements 137| 9| if arg.count != value.count { 138| 1| return false 139| 8| } 140| 8| 141| 8| // verify equality between array elements 142| 8| if arg.count > 0 { 143| 11| for i in 0...arg.count-1 { 144| 11| if !self.equal(arg[i], to: value[i]) { 145| 3| return false 146| 8| } 147| 8| } 148| 5| } 149| 5| 150| 5| return true 151| 8| } 152| | 153| |} <<<<<< EOF # path=fixes ./Example.playground/Contents.swift:2,3,5,8,11,15,16,17,20,23,26,29,32,36,37,38,39,40,41,47,48,49,52,55,56,59,60,63,64,65,66,67,69,70,72,76,79,84,87,88,91,92,95,96,97,101,109,110,113,114,117 ./Tests/LinuxMain.swift:2,4,7 ./Tests/InstantMockTests/Mocks/ArgumentAnyMock.swift:8,10,11,13,15,18,19,20 ./Tests/InstantMockTests/Mocks/ArgumentVerifyOptionalMock.swift:8,10,11,13,17,18,19,21,24,25,26 ./Tests/InstantMockTests/Mocks/ArgumentFactoryMock.swift:8,10,11,13,14,21,22,27,28,29,34,35,36,41,42,43,48,49,50,55,56,57,62,63,64,65 ./Tests/InstantMockTests/Mocks/ArgumentValueMock.swift:8,10,11,13,17,18,20,26,28,29,30 ./Tests/InstantMockTests/Mocks/ArgumentVerifyMandatoryMock.swift:8,10,11,13,17,18,19,21,24,25,26 ./Tests/InstantMockTests/Mocks/AssertionMock.swift:8,10,11,14,18,20,25,26,32,33,34 ./Tests/InstantMockTests/Mocks/ArgumentStorageMock.swift:8,10,11,13,16,17,21,22,25,26,27 ./Tests/InstantMockTests/Mocks/ArgumentClosureMock.swift:8,10,11,13,15,18,19,20 ./Tests/InstantMockTests/Mocks/ArgumentCaptureMock.swift:8,10,11,13,15,18,19,23,24,27,28,29 ./Tests/InstantMockTests/Mocks/ExpectationFactoryMock.swift:8,10,11,13,15,18,19,22,23,26,27,28 ./Tests/InstantMockTests/Mocks/VerifierMock.swift:8,10,11,14,17,19,25,26,27 ./Tests/InstantMockTests/Integration Tests/TypesMockTests.swift:8,11,12,14,15,27,28,29,31,34,35,38,39,42,43,46,47,50,51,54,55,58,59,62,63,66,67,70,71,74,75,78,79,82,83,86,87,90,91,92,93,94,96,99,100,106,107,108,111,114,116,119,120,121,124,127,129,132,133,134,137,140,142,145,146,147,150,153,155,158,159,160,163,166,168,171,172,173,176,179,181,184,185,186,189,192,194,197,198,199,202,205,207,210,211,212,214,216,219,221,224,225,226,229,232,234,237,238,239,243,246,248,251,252,253,257,259,262,264,267,268,269,273,275,278,280,283,284,285,288,291,293,296,297,298,302,304,307,309,312,313,314 ./Tests/InstantMockTests/Integration Tests/CaptureMockTests.swift:8,11,12,14,16,20,28,36,37,38,40,43,44,47,48,51,52,55,56,59,60,63,64,67,68,71,72,75,76,79,80,83,84,87,88,91,92,95,96,97,98,99,101,104,105,108,109,110,116,117,118,120,124,128,131,134,138,141,142,143,145,148,151,152,155,160,161,162,166,170,175,176,177,181,185,193,195,196,197,201,205,210,211,212,216,220,228,230,231,232,236,240,245,246,247,251,255,263,265,266,267,271,275,280,281,282,286,290,298,300,301,302,306,310,315,316,317,321,325,333,335,336,337,341,345,350,351,352,356,360,368,370,371,372 ./Tests/InstantMockTests/Integration Tests/ThrowingMockTests.swift:8,11,12,16,17,18,20,23,24,27,28,29,30,31,33,36,37,40,41,47,48,49,54,55,56,57,60,64,65,66,71,72,73,74 ./Tests/InstantMockTests/Integration Tests/BasicMockTests.swift:8,11,12,13,20,21,22,23,25,29,30,33,34,37,38,41,42,45,46,47,48,49,50,52,55,56,62,63,64,69,73,74,75,78,82,83,84,87,91,92,93,98,102,106,107,108,114,115,116,122,123,124,130,131,132,137,141,142,143,148,152,156,157,158,163,164,168,169,170,172,175,178,179,180,182,186,187,191,192,193,195,201,204,207,208,209,214,218,219,220,225,229,230,231,236,239,243,244,245,251,252,253,259,260,261,266,269,270,271,274,275,279,282,283,284,287,290,294,296,297,298 ./Tests/InstantMockTests/Integration Tests/ClosureMockTests.swift:8,9,12,13,15,16,18,22,30,31,32,34,37,38,41,42,45,46,49,50,53,54,57,58,61,62,65,66,67,68,69,71,74,75,81,82,83,89,93,96,97,98,104,106,109,110,111,117,121,124,125,126,129,131,134,135,136,139,141,144,145,146,149,151,154,155,156,159,161,164,165,166,169,171,174,175,176,179,181,184,185,186 ./Tests/InstantMockTests/Integration Tests/VerifyMockTests.swift:8,11,12,16,17,18,20,23,24,27,28,29,30,31,33,36,37,43,44,45,47,52,56,57,58,60,64,69,72,75,76,77,84,88,89,90 ./Tests/InstantMockTests/Integration Tests/MockCreationModalityTests.swift:8,11,12,15,16,17,19,22,23,24,25,26,28,31,35,36,39,40,43,44,45,46,47,49,52,56,57,58,61,62,65,66,69,70,73,74,77,78,81,82,83,84,85,87,90,91,96,97,98,102,104,107,108,109,113,115,118,119,120,124,126,129,130,131 ./Tests/InstantMockTests/Unit Tests/Interceptors/StubTests.swift:8,11,12,14,17,18,23,24,25,29,30,31,36,37,38,42,44,47,48,49,50,55,56,57,62,63,64,68,71,72,73,77,81,82,83,87,91,92,93,98,101,102,103,107,108,109,114,115,116,121,122,123,128,129,130,133,136,139,140,141,146,149,152,156,159,160,161,167,169,170,171,176,177,178,184,186,187,188,193,194,195 ./Tests/InstantMockTests/Unit Tests/Interceptors/ExpectationTests.swift:8,11,12,14,17,18,23,24,25,29,30,31,35,36,37,42,47,48,49,52,56,61,62,63,67,70,73,74,75,79,83,88,89,90,94,96,100,105,106,107,112,115,117,120,121,122,127,130,133,134,135,138,141,143,147,152,153,154,160,166,167,168,174,176,182,183,184,185 ./Tests/InstantMockTests/Unit Tests/Interceptors/Helpers/CallConfigurationTests.swift:8,11,12,14,15,19,22,24,25,26,30,33,35,36,37 ./Tests/InstantMockTests/Unit Tests/Interceptors/CallInterceptorStorageTests.swift:8,11,12,14,17,18,23,24,25,29,32,33,34,38,41,45,48,49,50,53,56,59,65,66,67,75,76,77 ./Tests/InstantMockTests/Unit Tests/Interceptors/CallInterceptorTests.swift:8,11,12,14,15,18,21,23,24,25,30,36,39,42,43,44,49,54,57,59,60,61 ./Tests/InstantMockTests/Unit Tests/Verifications/VerifierTests.swift:8,11,12,14,16,17,21,22,23,27,28,29,33,34,35,39,40,41,45,46,47,51,52,53,57,58,59,63,64,65,69,70,71,76,77,78,82,85,86,87,91,94,95,96,100,103,104,105,109,112,116,117,118,122,125,128,129,130,134,137,138,139,144,147,150,151,152,158,163,168,173,178,179,180,184,187,189,192,193,194 ./Tests/InstantMockTests/Unit Tests/MockUsable/StringMockUsableTests.swift:8,11,12,14,15,19,20,21,25,26,27,31,32,33,37,38,39,40 ./Tests/InstantMockTests/Unit Tests/MockUsable/SetMockUsableTests.swift:8,11,12,14,15,19,20,21,25,26,27,31,34,37,38,39,43,46,49,50,51 ./Tests/InstantMockTests/Unit Tests/MockUsable/DateMockUsableTests.swift:8,11,12,14,15,19,20,21,25,26,27,31,32,33,37,38,39,40 ./Tests/InstantMockTests/Unit Tests/MockUsable/BoolMockUsableTests.swift:8,11,12,14,18,19,20,24,25,26,30,31,32,36,37,38,39 ./Tests/InstantMockTests/Unit Tests/MockUsable/FloatMockUsableTests.swift:8,11,12,14,15,19,20,21,25,26,27,31,32,33,37,38,39,40 ./Tests/InstantMockTests/Unit Tests/MockUsable/IntMockUsableTests.swift:8,11,12,14,15,19,20,21,25,26,27,31,32,33,37,38,39,43,44,45,49,50,51 ./Tests/InstantMockTests/Unit Tests/MockUsable/ArrayMockUsableTests.swift:8,11,12,14,18,19,20,24,25,26,30,33,36,37,38,42,45,48,49,50 ./Tests/InstantMockTests/Unit Tests/MockUsable/DoubleMockUsableTests.swift:8,11,12,14,15,19,20,21,25,26,27,31,32,33,37,38,39,40 ./Tests/InstantMockTests/Unit Tests/MockUsable/DictionaryMockUsableTests.swift:8,11,12,14,15,19,20,21,25,26,27,31,34,37,38,39,43,46,49,50,51,55,58,61,62,63,73,75,76,77 ./Tests/InstantMockTests/Unit Tests/DefaultValue/DefaultClosureHandlerTests.swift:8,11,12,14,18,19,20,24,25,26,30,31,32,36,37,38,42,43,44,48,49,50,51 ./Tests/InstantMockTests/Unit Tests/DefaultValue/DefaultValueHandlerTests.swift:8,9,12,13,15,16,18,19,23,24,25,29,30,31 ./Tests/InstantMockTests/Unit Tests/Factories/ExpectationFactoryTests.swift:8,12,13,15,16,20,21,22,26,27,28 ./Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentCaptureTests.swift:8,9,12,13,15,17,21,22,23,27,28,29,33,34,35,39,40,41,45,46,47,50,53,56,57,58,61,64,67,68,69,72,75,78,79,80,84,87,92,93,94 ./Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentClosureTests.swift:8,11,12,14,15,20,21,22,27,28,29 ./Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentValueTests.swift:8,11,12,14,16,17,21,22,23,28,32,33,34,38,43,44,45 ./Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentVerifyMandatoryTests.swift:8,11,12,14,16,20,21,22,26,27,28,32,33,34,38,39,40 ./Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentAnyTests.swift:8,11,12,14,19,20,21,26,27,28 ./Tests/InstantMockTests/Unit Tests/Arguments/Arg/ArgumentVerifyOptionalTests.swift:8,11,12,14,16,20,21,22,26,27,28,32,33,34,38,39,40,44,45,46 ./Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptorTests+FourArgs.swift:8,11,12,14,18,19,25,26,27,31,34,37,41,42,43,47,49,52,55,58,59,60,64,66,69,72,75,76,77,78 ./Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptorTests+FiveArgs.swift:8,11,12,14,18,19,25,26,27,31,34,37,41,42,43,47,49,52,55,58,59,60,64,66,69,72,75,76,77 ./Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptorTests+OneArg.swift:8,11,12,14,18,19,25,26,27,30,33,36,39,40,41,44,46,49,52,55,56,57,60,62,65,68,71,72,73,74 ./Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptorTests+NoArg.swift:8,11,12,14,18,19,25,26,27,30,33,36,39,40,41,44,46,49,52,55,56,57,60,62,65,68,71,72,73 ./Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptorTests+ThreeArgs.swift:8,11,12,14,18,19,25,26,27,31,34,37,41,42,43,47,49,52,55,58,59,60,63,65,68,71,74,75,76 ./Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+TwoArgs.swift:8,11,12,14,18,19,25,26,27,30,33,36,39,40,41,44,46,49,52,55,56,57,60,62,65,68,71,72,73,74,75 ./Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentCaptorTests.swift:8,9,12,13,15,19,20,26,27,28,31,34,37,40,41,42,45,48,51,52,53,56,59,62,63,64 ./Tests/InstantMockTests/Unit Tests/Arguments/Captor/ArgumentCaptorValuesTests.swift:8,11,12,14,15,20,26,27,28,33,39,40,41 ./Tests/InstantMockTests/Unit Tests/Arguments/Arg+ClosureTests.swift:8,9,12,13,15,17,21,22,26,29,30,31,35,38,39,40,44,47,48,49,54,57,58,59,64,67,68,69,74,77,78,79,80,81 ./Tests/InstantMockTests/Unit Tests/Arguments/Helpers/ArgumentsConfigurationTests.swift:8,11,12,14,15,17,18,23,24,25,30,31,32,37,40,41,42,46,49,52,55,58,61,62,63,68,71,74,77,78,79 ./Tests/InstantMockTests/Unit Tests/Arguments/Helpers/ArgumentsMatcherTests.swift:8,11,13,14,16,17,20,23,26,27,28,32,34,37,38,39,44,47,49,52,55,56,57 ./Tests/InstantMockTests/Unit Tests/Arguments/Helpers/ArgumentStorageTests.swift:8,11,12,14,16,20,21,22,26,29,32,37,38,39,44,47,49,52,53,54 ./Tests/InstantMockTests/Unit Tests/Arguments/ArgTests.swift:8,9,12,13,15,17,19,23,24,25,31,35,38,42,43,44,50,54,55,56,63,67,72,76,77,78,85,89,90,91,97,100,105,106,107,113,116,117,118,122,125,128,129,130 ./Tests/InstantMockTests/XCTestManifests.swift:3,16,17,31,32,41,42,52,53,62,63,78,79,89,90,100,101,111,112,122,123,133,134,144,145,154,155,164,165,174,175,185,186,197,198,210,211,221,222,233,234,260,261,272,273,282,283,294,295,305,306,327,328,344,345,356,357,370,371,380,381,394,395,406,407,416,417,436,437,448,449,462,463,473,474,485,486,497,498,524,525,535,536,558,559,584,585,595,596,644 ./Package.swift:3,5 ./Sources/InstantMock/Interceptors/Expectation.swift:8,9,12,13,16,19,22,25,28,29,31,35,36,37,43,44,45,47,53,54,55,56,57,58,61,67,68,69,70,71,74,75,80,82,83,84,89,91,92,93,97,100,105,106,109,110,112,113,114,118,121,126,127,130,131,133,134,135,139,144,145,146,147 ./Sources/InstantMock/Interceptors/Stub.swift:8,9,12,15,18,21,24,27,31,32,33,35,40,44,45,48,52,53,57,61,62,64,65,66,70,74,77,78,79,80,81,82,83,84,87,93,94,95,96,97,98,101,102,109,110,111,117,118,119,125,126,127,133,134,135,136,137,140,141,145,146,147,153,154,155,156,157,160,161,165,167,168,169,173,175 ./Sources/InstantMock/Interceptors/CallInterceptor.swift:8,9,12,15,16,21,22,23,24,25,28,31,34,40,42,43,44,45,46 ./Sources/InstantMock/Interceptors/Helpers/CallInterceptorStorage.swift:8,9,12,13,16,17,28,29,30,38,39,40,45,46,47,51,52 ./Sources/InstantMock/Interceptors/Helpers/CallConfiguration.swift:8,9,12,15,18,19,24,25,26,27,28,31,34,35,38 ./Sources/InstantMock/Property/Property.swift:8,9,12,15,16,20,21,22,27,28,29,30 ./Sources/InstantMock/Verifications/Verifier.swift:8,9,13,14,15,18,19,22,23,31,36,39,40,41,49,53,54,58,59,63,64,68,69,73,74,77,78,79,89,90,91,95,97,98,99,103,105,106,107,113,115,116,117,123,125,126,127,135,139,140,146,147,148,149,151,152,153 ./Sources/InstantMock/Verifications/Assertion.swift:8,10,11,14,21,29,30,31,34,37,38,41,42,43,45,51,52,53,54,55 ./Sources/InstantMock/Mock.swift:8,9,12,15,16,17,20,23,24,25,28,32,33,34,37,40,41,42,49,51,55,57,60,63,67,71,74,78,83,84,85,87,91,92,93,99,100,105,106,107,108,109,110,113,116,119,122,126,128,129,130,133,136,139,143,145,146,147,148,149,152,161,162,163,164,172,176,179,182,183,184,191,194,201,202,203,204,205,206,207,208,211,215,218,221,223,224,225,233,237,240,243,244,245,254,257,265,267,268,270,271,272,273,274,277,282,283,284,288,289,290,295,296,297,301,302,303,308,313,314,316,317,318,326,329,333,334,337,341,342,343,352,357,361,362,366,367,369,370,371,382,383,387,388,389,390,400,404,408,409,411,412,413 ./Sources/InstantMock/MockUsable/MockUsable.swift:8,9,12,15,18,19 ./Sources/InstantMock/MockUsable/Bool+MockUsable.swift:8,9,12,14,17,18,22,23,24 ./Sources/InstantMock/MockUsable/String+MockUsable.swift:8,9,12,14,17,18,22,23,24 ./Sources/InstantMock/MockUsable/Int+MockUsable.swift:8,11,15,16,17,18,21,24,25,28,31,32,35,38,39,42,45,46 ./Sources/InstantMock/MockUsable/Array+MockUsable.swift:8,9,12,15,16,19,20,24,25,26 ./Sources/InstantMock/MockUsable/Double+MockUsable.swift:8,9,12,14,17,18,22,23,24 ./Sources/InstantMock/MockUsable/Float+MockUsable.swift:8,9,12,14,17,18,22,23,24 ./Sources/InstantMock/MockUsable/Date+MockUsable.swift:8,10,13,15,18,19,23,24,25 ./Sources/InstantMock/MockUsable/Dictionary+MockUsable.swift:8,9,12,15,16,19,20,23,27,30,33,34,39,40,41,43,44,45 ./Sources/InstantMock/MockUsable/Set+MockUsable.swift:8,9,12,15,16,19,20,24,25,26 ./Sources/InstantMock/DefaultValue/DefaultValueHandler.swift:8,9,12,13,17,22,23,24,26,27,28 ./Sources/InstantMock/DefaultValue/DefaultClosureHandler.swift:8,9,12,17,18,23,24,29,30,35,36,41,42,47,48,49 ./Sources/InstantMock/Factories/ExpectationFactory.swift:8,9,12,15,18,19,20,23,26,29,30,33,34,35 ./Sources/InstantMock/Arguments/Arg.swift:8,9,12,13,15,20,21,22,27,28,29,33,37,38,39,43,47,48,49,51,56,57,58,63,64,65,69,72,76,78,79,80,84,88,91,92,93,94,95,98,99,101,106,107,108,113,114,115,118,123,127,129,130,131 ./Sources/InstantMock/Arguments/Argument/Argument.swift:8,9,12,13,16,19 ./Sources/InstantMock/Arguments/Argument/ArgumentVerify/ArgumentVerify.swift:8,9 ./Sources/InstantMock/Arguments/Argument/ArgumentVerify/ArgumentVerifyMandatory.swift:8,9,15,16,17,20,23,24,28,29,30,31,32,35,38,42,43,45,46,47,48,49,52,55,56,57 ./Sources/InstantMock/Arguments/Argument/ArgumentVerify/ArgumentVerifyOptional.swift:8,9,15,16,17,20,23,24,28,29,30,31,32,35,38,42,43,45,46,47,48,49,52,55,56,57 ./Sources/InstantMock/Arguments/Argument/ArgumentValue.swift:8,9,12,13,19,20,21,24,27,30,31,33,37,38,43,44,45,46,47,50,53,54,55,56,57,60,63,68,69,71,72,73 ./Sources/InstantMock/Arguments/Argument/ArgumentCapture.swift:8,9,15,16,17,20,23,26,30,31,37,39,40,44,45,49,50,51,53,57,58,59,60,61,64,68,69,70,71,72,75,81,82,83,84,85,86,89,92,93,94 ./Sources/InstantMock/Arguments/Argument/ArgumentClosure.swift:8,9,12,13,16,19,20,24,25,26,27,28,31,34,35,36,37,38,41,44,45,46 ./Sources/InstantMock/Arguments/Argument/ArgumentAny.swift:8,9,12,13,16,19,20,24,25,26,27,28,31,34,35,36,37,38,41,44,45,46 ./Sources/InstantMock/Arguments/Arg+Closure.swift:8,9,12,17,18,19,23,28,31,32,33,38,39,40,44,49,52,53,54,59,60,61,65,70,73,74,75,80,81,82,86,91,94,95,96,102,103,104,108,113,116,117,118,122,126,127,128,132,137,140,141,142 ./Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+ThreeArgs.swift:8,9,12,13,18,19,20,26,27,28,32,38,40,41,42,43,44 ./Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+TwoArgs.swift:8,9,12,13,18,19,20,25,26,27,31,37,39,40,41,42 ./Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+NoArg.swift:8,9,12,13,18,19,20,25,26,27,31,37,39,40,41,42 ./Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+FourArgs.swift:8,9,12,13,19,20,21,27,28,29,33,39,41,42,43,44 ./Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+OneArg.swift:8,9,12,13,18,19,20,25,26,27,31,37,39,40,41 ./Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor/ArgumentClosureCaptor+FiveArgs.swift:8,9,12,13,19,20,21,25,29,30,31,35,41,43,44,45,46 ./Sources/InstantMock/Arguments/Captor/ArgumentCaptorValues.swift:8,9,15,16,17,20,23,29,31,32,38,40,41,42,46,47,48,49 ./Sources/InstantMock/Arguments/Captor/ArgumentClosureCaptor.swift:8,9,12,15,20,23,24,25,26,29,32,33,36,37,38 ./Sources/InstantMock/Arguments/Captor/ArgumentCaptor.swift:8,9,12,15,20,23,24,25,26,29,34,35,36,39,45,49,51,52,53,54,55,58,61,62,65,66,67 ./Sources/InstantMock/Arguments/Helpers/ArgumentFactory.swift:8,9,13,16,19,22,26,29,30,31,34,37,38,41,42,45,46,49,50,53,54,57,58,59 ./Sources/InstantMock/Arguments/Helpers/ArgumentsConfiguration.swift:8,9,12,15,16,20,21,22,23,24,27,30,36,37,39,40,41,42,43,46,50,51,55,56,57,58,59,62,66,67,68,73,75 ./Sources/InstantMock/Arguments/Helpers/ArgumentsMatcher.swift:8,9,12,15,19,20,21,22,23,26,27,30,34,35,41,44,45,46,47,49,50,51 ./Sources/InstantMock/Arguments/Helpers/ArgumentStorage.swift:8,9,12,15,18,21,22,23,24,27,30,33,34,35,38,41,42,45,46,49,50,51 ./Sources/InstantMock.h:8,10,13,16,18,19 <<<<<< EOF