diff --git a/.travis.yml b/.travis.yml index 6c370a9..3874ac7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ cache: bundler: true directories: - "./Carthage" -osx_image: xcode8.3 +osx_image: xcode9.2 # before_install: before_script: diff --git a/Cartfile.private b/Cartfile.private index c59c25a..b3051eb 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1,2 @@ -github "Quick/Quick" "v0.10.0" -github "Quick/Nimble" "v5.1.1" +github "Quick/Quick" ~> 1.2.0 +github "Quick/Nimble" ~> 7.0.2 diff --git a/Cartfile.resolved b/Cartfile.resolved index 0ddbdc6..afbb73e 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "Quick/Nimble" "v5.1.1" -github "Quick/Quick" "v0.10.0" +github "Quick/Nimble" "v7.0.3" +github "Quick/Quick" "v1.2.0" diff --git a/PiedPiper/Future+Recover.swift b/PiedPiper/Future+Recover.swift index 3d4db26..c665e2f 100644 --- a/PiedPiper/Future+Recover.swift +++ b/PiedPiper/Future+Recover.swift @@ -23,7 +23,7 @@ extension Future { - returns: A new Future that will behave as this Future, except when this Future fails. In that case, it will succeed with the rescue value */ - public func recover(_ handler: @escaping (Void) -> T) -> Future { + public func recover(_ handler: @escaping () -> T) -> Future { return _recover { recovered in recovered.succeed(handler()) } @@ -47,7 +47,7 @@ extension Future { - returns: A new Future that will behave as this Future, except when this Future fails. In that case, it will mimic the outcome of the Future provided by the handler */ - public func recover(_ handler: @escaping (Void) -> Future) -> Future { + public func recover(_ handler: @escaping () -> Future) -> Future { return _recover { recovered in recovered.mimic(handler()) } @@ -60,7 +60,7 @@ extension Future { - returns: A new Future that will behave as this Future, except when this Future fails. In that case, it will mimic the outcome of the Result provided by the handler */ - public func recover(_ handler: @escaping (Void) -> Result) -> Future { + public func recover(_ handler: @escaping () -> Result) -> Future { return _recover { recovered in recovered.mimic(handler()) } diff --git a/PiedPiper/Future+Retry.swift b/PiedPiper/Future+Retry.swift index 2a0aebe..76541b5 100644 --- a/PiedPiper/Future+Retry.swift +++ b/PiedPiper/Future+Retry.swift @@ -9,7 +9,7 @@ import Foundation - returns: A future that fails if all the generated futures have failed, or succeeds if one of the generated futures succeeds */ -public func retry(_ count: Int, every delay: TimeInterval, futureClosure: @escaping (Void) -> Future) -> Future { +public func retry(_ count: Int, every delay: TimeInterval, futureClosure: @escaping () -> Future) -> Future { if count <= 0 { return futureClosure() } @@ -18,7 +18,7 @@ public func retry(_ count: Int, every delay: TimeInterval, futureClosure: @es result.mimic( futureClosure() - .recover { Void -> Future in + .recover { () -> Future in let delayed = Promise() GCD.delay(delay, closure: {}).onSuccess { diff --git a/PiedPiper/Future.swift b/PiedPiper/Future.swift index 96cd0aa..ff1a139 100644 --- a/PiedPiper/Future.swift +++ b/PiedPiper/Future.swift @@ -43,7 +43,7 @@ open class Future: Async { The initialized future will succeed if the result of the closure is .Some, and will fail with a FutureInitializationError.ClosureReturnedNil if it's .None. The future will report on the main queue */ - public convenience init(closure: @escaping (Void) -> T?) { + public convenience init(closure: @escaping () -> T?) { let promise = Promise() self.init(promise: promise) @@ -95,7 +95,7 @@ open class Future: Async { - returns: The updated Future */ @discardableResult - public func onCancel(_ callback: @escaping (Void) -> Void) -> Future { + public func onCancel(_ callback: @escaping () -> Void) -> Future { promise.onCancel(callback) return self diff --git a/PiedPiper/GCD.swift b/PiedPiper/GCD.swift index 340520a..fcdcf92 100644 --- a/PiedPiper/GCD.swift +++ b/PiedPiper/GCD.swift @@ -13,7 +13,7 @@ public struct GCD: GCDQueue { - returns: The result of the execution of the closure */ @discardableResult - public static func main(_ closure: @escaping ((Void) -> T)) -> AsyncDispatch { + public static func main(_ closure: @escaping (() -> T)) -> AsyncDispatch { return mainQueue.async(closure) } @@ -25,7 +25,7 @@ public struct GCD: GCDQueue { - returns: The result of the execution of the closure */ @discardableResult - static public func background(_ closure: @escaping ((Void) -> T)) -> AsyncDispatch { + static public func background(_ closure: @escaping (() -> T)) -> AsyncDispatch { return backgroundQueue.async(closure) } @@ -45,7 +45,7 @@ public struct GCD: GCDQueue { } @discardableResult - static func delay(_ time: TimeInterval, closure: @escaping (Void) -> T) -> Future { + static func delay(_ time: TimeInterval, closure: @escaping () -> T) -> Future { let result = Promise() let time = DispatchTime.now() + Double(Int64(time * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC) @@ -132,7 +132,7 @@ extension GCDQueue { - returns: An AsyncDispatch object. You can keep chaining async calls on this object */ @discardableResult - public func async(_ closure: @escaping (Void) -> T) -> AsyncDispatch { + public func async(_ closure: @escaping () -> T) -> AsyncDispatch { let innerResult = Promise() let result = AsyncDispatch(operation: innerResult.future) diff --git a/PiedPiper/Promise.swift b/PiedPiper/Promise.swift index b63620b..bbd7ab4 100644 --- a/PiedPiper/Promise.swift +++ b/PiedPiper/Promise.swift @@ -6,7 +6,7 @@ open class Promise: Async { private var failureListeners: [(Error) -> Void] = [] private var successListeners: [(T) -> Void] = [] - private var cancelListeners: [(Void) -> Void] = [] + private var cancelListeners: [() -> Void] = [] private var error: Error? private var value: T? private var canceled = false @@ -188,7 +188,7 @@ open class Promise: Async { - returns: The updated Promise */ @discardableResult - public func onCancel(_ callback: @escaping (Void) -> Void) -> Promise { + public func onCancel(_ callback: @escaping () -> Void) -> Promise { if canceled { callback() } else { diff --git a/PiedPiperSample.xcodeproj/project.pbxproj b/PiedPiperSample.xcodeproj/project.pbxproj index aa08c7e..33dd972 100644 --- a/PiedPiperSample.xcodeproj/project.pbxproj +++ b/PiedPiperSample.xcodeproj/project.pbxproj @@ -436,7 +436,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = WeltN24; TargetAttributes = { 52B29CF31CEA236E00B5B277 = { @@ -444,15 +444,15 @@ }; 52BED2A31CE870F2002C045A = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0920; }; 52BED2CF1CE87175002C045A = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0920; }; 52BED3011CE8719D002C045A = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0920; ProvisioningStyle = Manual; TestTargetID = 52BED2A31CE870F2002C045A; }; @@ -663,7 +663,7 @@ PRODUCT_NAME = PiedPiper; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -689,7 +689,7 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -704,14 +704,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -751,14 +757,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -792,7 +804,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = de.weltn24.PiedPiperSample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -806,7 +819,8 @@ PRODUCT_BUNDLE_IDENTIFIER = de.weltn24.PiedPiperSample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -831,7 +845,8 @@ SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvos appletvsimulator watchos watchsimulator"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2,3,4"; TVOS_DEPLOYMENT_TARGET = 9.0; VALID_ARCHS = "arm64 armv7 armv7s armv7k"; @@ -862,7 +877,8 @@ SKIP_INSTALL = YES; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvos appletvsimulator watchos watchsimulator"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2,3,4"; TVOS_DEPLOYMENT_TARGET = 9.0; VALID_ARCHS = "arm64 armv7 armv7s armv7k"; @@ -885,7 +901,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = de.weltn24.PiedPiperTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PiedPiperSample.app/PiedPiperSample"; }; name = Debug; @@ -904,7 +921,8 @@ PRODUCT_BUNDLE_IDENTIFIER = de.weltn24.PiedPiperTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PiedPiperSample.app/PiedPiperSample"; }; name = Release; diff --git a/PiedPiperSample.xcodeproj/xcshareddata/xcschemes/PiedPiper-Mac.xcscheme b/PiedPiperSample.xcodeproj/xcshareddata/xcschemes/PiedPiper-Mac.xcscheme index 3074a31..53286b3 100644 --- a/PiedPiperSample.xcodeproj/xcshareddata/xcschemes/PiedPiper-Mac.xcscheme +++ b/PiedPiperSample.xcodeproj/xcshareddata/xcschemes/PiedPiper-Mac.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/PiedPiperSample.xcodeproj/xcshareddata/xcschemes/PiedPiper.xcscheme b/PiedPiperSample.xcodeproj/xcshareddata/xcschemes/PiedPiper.xcscheme index 77d913a..8bf3558 100644 --- a/PiedPiperSample.xcodeproj/xcshareddata/xcschemes/PiedPiper.xcscheme +++ b/PiedPiperSample.xcodeproj/xcshareddata/xcschemes/PiedPiper.xcscheme @@ -1,6 +1,6 @@ Int = { + let first: () -> Int = { 5 } @@ -15,19 +15,19 @@ class FunctionCompositionTests: QuickSpec { "\($0)" } - var composed: ((Void) -> String)! + var composed: ((()) -> String)! beforeEach { composed = first >>> second } it("should return the right value") { - expect(composed()).to(equal("5")) + expect(composed(())).to(equal("5")) } } context("when the first function takes no parameter, and the second does but returns void") { - let first: (Void) -> Int = { + let first: () -> Int = { 5 } @@ -35,11 +35,11 @@ class FunctionCompositionTests: QuickSpec { print("\($0)") } - var composed: ((Void) -> Void)! + var composed: ((()) -> Void)! beforeEach { composed = first >>> second - composed() + composed(()) } it("should swallow the parameter") { @@ -52,7 +52,7 @@ class FunctionCompositionTests: QuickSpec { print(input) } - let second: (Void) -> String = { + let second: () -> String = { "hello!" } @@ -72,7 +72,7 @@ class FunctionCompositionTests: QuickSpec { print(input) } - let second: (Void) -> Void = { + let second: () -> Void = { print("hello!") } @@ -89,39 +89,39 @@ class FunctionCompositionTests: QuickSpec { } context("when both functions take no parameter") { - let first: (Void) -> Void = { + let first: () -> Void = { print("hello...") } - let second: (Void) -> String = { + let second: () -> String = { "...world!" } - var composed: ((Void) -> String)! + var composed: ((()) -> String)! beforeEach { composed = first >>> second } it("should return the right value") { - expect(composed()).to(equal("...world!")) + expect(composed(())).to(equal("...world!")) } } context("when both functions take no parameter and the second returns void") { - let first: (Void) -> Void = { + let first: () -> Void = { print("hello...") } - let second: (Void) -> Void = { + let second: () -> Void = { print("...world!") } - var composed: ((Void) -> Void)! + var composed: ((()) -> Void)! beforeEach { composed = first >>> second - composed() + composed(()) } it("should swallow the parameter") { diff --git a/PiedPiperTests/Future+RecoverTests.swift b/PiedPiperTests/Future+RecoverTests.swift index 27d4c3b..9858345 100644 --- a/PiedPiperTests/Future+RecoverTests.swift +++ b/PiedPiperTests/Future+RecoverTests.swift @@ -20,7 +20,7 @@ class FutureRecoverTests: QuickSpec { } context("when done through a closure") { - let rescueClosure: (Void) -> String = { + let rescueClosure: () -> String = { "rescued!" } diff --git a/PiedPiperTests/Future+ReduceTests.swift b/PiedPiperTests/Future+ReduceTests.swift index 228b0b3..ed2178e 100644 --- a/PiedPiperTests/Future+ReduceTests.swift +++ b/PiedPiperTests/Future+ReduceTests.swift @@ -9,7 +9,7 @@ extension MutableCollection where Self.Index == Int { for i in startIndex ..< endIndex - 1 { let j = Int(arc4random_uniform(UInt32(endIndex - i))) + i if i != j { - swap(&self[i], &self[j]) + self.swapAt(i, j) } } diff --git a/PiedPiperTests/Future+RetryTests.swift b/PiedPiperTests/Future+RetryTests.swift index 7bba8b3..0586c76 100644 --- a/PiedPiperTests/Future+RetryTests.swift +++ b/PiedPiperTests/Future+RetryTests.swift @@ -8,7 +8,7 @@ class FutureRetryTests: QuickSpec { describe("Retrying a given future") { var lastPromise: Promise? var retryCount: Int! - let futureClosure: (Void) -> Future = { + let futureClosure: () -> Future = { lastPromise = Promise() retryCount = retryCount + 1 return lastPromise!.future diff --git a/PiedPiperTests/PromiseTests.swift b/PiedPiperTests/PromiseTests.swift index c3743fa..4b0c8a0 100644 --- a/PiedPiperTests/PromiseTests.swift +++ b/PiedPiperTests/PromiseTests.swift @@ -46,7 +46,7 @@ class PromiseTests: QuickSpec { var failureCompletedSentinels: [Error?]! var cancelCompletedSentinels: [Bool?]! - let resetSentinels: (Void) -> Void = { + let resetSentinels: () -> Void = { successSentinels = [String?](repeating: nil, count: sentinelsCount) failureSentinels = [Error?](repeating: nil, count: sentinelsCount) cancelSentinels = [Bool?](repeating: nil, count: sentinelsCount)