Created
March 31, 2019 18:02
-
-
Save polac24/63d658ce0b460504de95610f4b1e257d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func stub<I,O>(of: (I) throws -> (O)) -> (I) throws -> (O){ | |
return nil! | |
} | |
func niceStub<I,O>(of: (I) throws -> (O), thatReturns: O) -> (I) throws -> (O){ | |
return { _ in thatReturns } | |
} | |
func niceStub<I,O,E:Error>(of: (I) throws -> (O), thatThrows error: E) -> (I) throws -> (O){ | |
return { _ in throw error } | |
} | |
func niceStub<I,O: DefaultProvidable>(of: (I) throws -> (O)) -> (I) throws -> (O){ | |
return { _ in O.defaultValue } | |
} | |
func spyCalls<I,O>(of stub: inout (I) throws -> (O)) -> (ArgRecords<I>) { | |
.... // copy&paste implementation of spyCalls | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment