From 578e5b5eb84fb2574b5eee7c986de060c48ca612 Mon Sep 17 00:00:00 2001 From: Greg Pardo Date: Thu, 24 Mar 2016 14:55:02 -0400 Subject: [PATCH 1/2] Update swift 2.2 --- Cartfile | 2 +- Cartfile.resolved | 3 +- Pipes.xcodeproj/project.pbxproj | 74 ++++++++-- .../xcshareddata/xcschemes/Pipes.xcscheme | 13 +- Pipes/Info.plist | 2 +- Pipes/PureHelpers.swift | 133 ++++++++++-------- PipesTests/BackwardPipeTests.swift | 6 +- PipesTests/ForwardPipeTests.swift | 44 +++--- PipesTests/Info.plist | 2 +- PipesTests/TestHelpers.swift | 21 --- 10 files changed, 169 insertions(+), 131 deletions(-) delete mode 100644 PipesTests/TestHelpers.swift diff --git a/Cartfile b/Cartfile index 168c6ce..74ad1ce 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "antitypical/Result" ~> 0.4 +github "antitypical/Result" "master" diff --git a/Cartfile.resolved b/Cartfile.resolved index cfc8cef..4bab36a 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1 @@ -github "robrix/Box" "1.2.2" -github "antitypical/Result" "0.4.2" +github "antitypical/Result" "89653c28708641d428b447bb5f3cbc69173ab8cb" diff --git a/Pipes.xcodeproj/project.pbxproj b/Pipes.xcodeproj/project.pbxproj index 47ad77a..01f1206 100644 --- a/Pipes.xcodeproj/project.pbxproj +++ b/Pipes.xcodeproj/project.pbxproj @@ -11,14 +11,13 @@ 1EA6037D1AEFE4BB00B1E32B /* Pipes.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EA603711AEFE4BB00B1E32B /* Pipes.framework */; }; 1EA6038E1AEFE53700B1E32B /* ForwardPipe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA6038D1AEFE53700B1E32B /* ForwardPipe.swift */; }; 1EA603901AEFE62400B1E32B /* ForwardPipeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA6038F1AEFE62400B1E32B /* ForwardPipeTests.swift */; }; - 1EA603921AEFE63900B1E32B /* TestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA603911AEFE63900B1E32B /* TestHelpers.swift */; }; 1EA603981AEFE8B800B1E32B /* BackwardPipe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA603971AEFE8B800B1E32B /* BackwardPipe.swift */; }; 1EA6039A1AF018C500B1E32B /* BackwardPipeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA603991AF018C500B1E32B /* BackwardPipeTests.swift */; }; 1EA6039C1AF0259100B1E32B /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA6039B1AF0259100B1E32B /* Result.swift */; }; - 1EA603A41AF0272600B1E32B /* Box.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EA603A21AF0272600B1E32B /* Box.framework */; }; - 1EA603A51AF0272600B1E32B /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EA603A31AF0272600B1E32B /* Result.framework */; }; 1EA603A91AF0298C00B1E32B /* Optional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA603A81AF0298C00B1E32B /* Optional.swift */; }; 1EE819001B0A40CB00445D9F /* PureHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE818FF1B0A40CB00445D9F /* PureHelpers.swift */; }; + 436ECAB51CA465410058B96A /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 436ECAB11CA464470058B96A /* Result.framework */; }; + 436ECAB91CA46EA00058B96A /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 436ECAB11CA464470058B96A /* Result.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -52,14 +51,12 @@ 1EA603821AEFE4BB00B1E32B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 1EA6038D1AEFE53700B1E32B /* ForwardPipe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForwardPipe.swift; sourceTree = ""; }; 1EA6038F1AEFE62400B1E32B /* ForwardPipeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForwardPipeTests.swift; sourceTree = ""; }; - 1EA603911AEFE63900B1E32B /* TestHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestHelpers.swift; sourceTree = ""; }; 1EA603971AEFE8B800B1E32B /* BackwardPipe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackwardPipe.swift; sourceTree = ""; }; 1EA603991AF018C500B1E32B /* BackwardPipeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackwardPipeTests.swift; sourceTree = ""; }; 1EA6039B1AF0259100B1E32B /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = ""; }; - 1EA603A21AF0272600B1E32B /* Box.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Box.framework; sourceTree = BUILD_PRODUCTS_DIR; }; - 1EA603A31AF0272600B1E32B /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Result.framework; sourceTree = BUILD_PRODUCTS_DIR; }; 1EA603A81AF0298C00B1E32B /* Optional.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Optional.swift; sourceTree = ""; }; 1EE818FF1B0A40CB00445D9F /* PureHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PureHelpers.swift; sourceTree = ""; }; + 436ECAB11CA464470058B96A /* Result.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Result.framework; path = Carthage/Build/iOS/Result.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -67,8 +64,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1EA603A41AF0272600B1E32B /* Box.framework in Frameworks */, - 1EA603A51AF0272600B1E32B /* Result.framework in Frameworks */, + 436ECAB51CA465410058B96A /* Result.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -76,6 +72,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 436ECAB91CA46EA00058B96A /* Result.framework in Frameworks */, 1EA6037D1AEFE4BB00B1E32B /* Pipes.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -86,8 +83,7 @@ 1EA603671AEFE4BB00B1E32B = { isa = PBXGroup; children = ( - 1EA603A21AF0272600B1E32B /* Box.framework */, - 1EA603A31AF0272600B1E32B /* Result.framework */, + 436ECAB11CA464470058B96A /* Result.framework */, 1EA603731AEFE4BB00B1E32B /* Pipes */, 1EA603801AEFE4BB00B1E32B /* PipesTests */, 1EA603721AEFE4BB00B1E32B /* Products */, @@ -129,7 +125,6 @@ isa = PBXGroup; children = ( 1EA603991AF018C500B1E32B /* BackwardPipeTests.swift */, - 1EA603911AEFE63900B1E32B /* TestHelpers.swift */, 1EA6038F1AEFE62400B1E32B /* ForwardPipeTests.swift */, 1EA603811AEFE4BB00B1E32B /* Supporting Files */, ); @@ -166,6 +161,7 @@ 1EA6036D1AEFE4BB00B1E32B /* Frameworks */, 1EA6036E1AEFE4BB00B1E32B /* Headers */, 1EA6039F1AF025C700B1E32B /* Copy Frameworks */, + 436ECAAF1CA464130058B96A /* ShellScript */, ); buildRules = ( ); @@ -183,6 +179,7 @@ 1EA603781AEFE4BB00B1E32B /* Sources */, 1EA603791AEFE4BB00B1E32B /* Frameworks */, 1EA6037A1AEFE4BB00B1E32B /* Resources */, + 436ECABA1CA46EAC0058B96A /* ShellScript */, ); buildRules = ( ); @@ -200,7 +197,9 @@ 1EA603681AEFE4BB00B1E32B /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastSwiftMigration = 0730; + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0730; ORGANIZATIONNAME = "Jason Larsen"; TargetAttributes = { 1EA603701AEFE4BB00B1E32B = { @@ -239,6 +238,37 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 436ECAAF1CA464130058B96A /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/Carthage/Build/iOS/Result.framework", + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/usr/local/bin/carthage copy-frameworks"; + }; + 436ECABA1CA46EAC0058B96A /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/Carthage/Build/iOS/Result.framework", + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/usr/local/bin/carthage copy-frameworks"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 1EA6036C1AEFE4BB00B1E32B /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -258,7 +288,6 @@ files = ( 1EA603901AEFE62400B1E32B /* ForwardPipeTests.swift in Sources */, 1EA6039A1AF018C500B1E32B /* BackwardPipeTests.swift in Sources */, - 1EA603921AEFE63900B1E32B /* TestHelpers.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -295,6 +324,7 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -370,14 +400,19 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); INFOPLIST_FILE = Pipes/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "me.jasonlarsen.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + VALID_ARCHS = "arm64 armv7 armv7s x86_64 i386"; }; name = Debug; }; @@ -389,13 +424,18 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); INFOPLIST_FILE = Pipes/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "me.jasonlarsen.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + VALID_ARCHS = "arm64 armv7 armv7s x86_64 i386"; }; name = Release; }; @@ -405,6 +445,7 @@ FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -412,6 +453,7 @@ ); INFOPLIST_FILE = PipesTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "me.jasonlarsen.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -422,9 +464,11 @@ FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = PipesTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "me.jasonlarsen.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/Pipes.xcodeproj/xcshareddata/xcschemes/Pipes.xcscheme b/Pipes.xcodeproj/xcshareddata/xcschemes/Pipes.xcscheme index b70e97e..4248b95 100644 --- a/Pipes.xcodeproj/xcshareddata/xcschemes/Pipes.xcscheme +++ b/Pipes.xcodeproj/xcshareddata/xcschemes/Pipes.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -62,15 +62,18 @@ ReferencedContainer = "container:Pipes.xcodeproj"> + + CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - me.jasonlarsen.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Pipes/PureHelpers.swift b/Pipes/PureHelpers.swift index 65bbc8c..f0a8d6d 100644 --- a/Pipes/PureHelpers.swift +++ b/Pipes/PureHelpers.swift @@ -8,100 +8,108 @@ import Foundation // MARK: Sequence // -public func map(f: S.Generator.Element->T)(seq: S) -> [T] { +/*public func map(f: S.Generator.Element->T, seq: S) -> [T] { return map(seq, f) -} +}*/ -public func filter(f: S.Generator.Element->Bool)(seq: S) -> [S.Generator.Element] { - return filter(seq, f) +public func filter(f: S.Generator.Element->Bool, seq: S) -> [S.Generator.Element] { + return seq.filter(f) } -public func reduce(initial: U, @noescape f: (U, S.Generator.Element) -> U)(seq: S) -> U { - return reduce(seq, initial, f) +public func reduce(initial: U, @noescape f: (U, S.Generator.Element) -> U, seq: S) -> U { + return seq.reduce(initial, combine: f) } // // MARK: ExtensibleCollectionType // -public func extend(var collection: C, newElements: S) -> C { - collection.extend(newElements) - return collection +public func extend( collection: C, newElements: S) -> C { + var c = collection + c.appendContentsOf(newElements) + return c } -public func extend(newElements: S)(collection: C) -> C { - return extend(collection, newElements) +public func extend(newElements: S, collection: C) -> C { + return extend(collection, newElements: newElements) } -public func append(var collection: C, newElement: C.Generator.Element) -> C { - collection.append(newElement) - return collection +public func append( collection: C, newElement: C.Generator.Element) -> C { + var c = collection + c.append(newElement) + return c } -public func append(newElement: C.Generator.Element)(collection: C) -> C { - return append(collection, newElement) +public func append(newElement: C.Generator.Element, collection: C) -> C { + return append(collection, newElement: newElement) } // // MARK: RangeReplaceableCollectionType // -public func replaceRange(var collection: R, subRange: Range, with newElements: C) -> R { - collection.replaceRange(subRange, with: newElements) - return collection +public func replaceRange( collection: R, subRange: Range, with newElements: C) -> R { + var c = collection + c.replaceRange(subRange, with: newElements) + return c } -public func replaceRange(subRange: Range, with newElements: C)(collection: R) -> R { - return replaceRange(collection, subRange, with: newElements) +public func replaceRange(subRange: Range, with newElements: C, collection: R) -> R { + return replaceRange(collection, subRange: subRange, with: newElements) } -public func insert(var collection: R, newElement: R.Generator.Element, atIndex i: R.Index) -> R { - collection.insert(newElement, atIndex: i) - return collection +public func insert( collection: R, newElement: R.Generator.Element, atIndex i: R.Index) -> R { + var c = collection + c.insert(newElement, atIndex: i) + return c } -public func insert(newElement: R.Generator.Element, atIndex i: R.Index)(collection: R) -> R { - return insert(collection, newElement, atIndex: i) +public func insert(newElement: R.Generator.Element, atIndex i: R.Index, collection: R) -> R { + return insert(collection, newElement: newElement, atIndex: i) } -public func splice(var collection: R, newElements: S, atIndex i: R.Index) -> R { - collection.splice(newElements, atIndex: i) - return collection +public func splice( collection: R, newElements: S, atIndex i: R.Index) -> R { + var c = collection + c.insertContentsOf(newElements, at: i) + return c } -public func splice(newElements: S, atIndex i: R.Index)(collection: R) -> R { - return splice(collection, newElements, atIndex: i) +public func splice(newElements: S, atIndex i: R.Index, collection: R) -> R { + return splice(collection, newElements: newElements, atIndex: i) } -public func removeAtIndex(var collection: R, i: R.Index) -> (R, R.Generator.Element) { - let element = collection.removeAtIndex(i) - return (collection, element) +public func removeAtIndex( collection: R, i: R.Index) -> (R, R.Generator.Element) { + var c = collection + let element = c.removeAtIndex(i) + return (c, element) } -public func removeAtIndex(i: R.Index)(collection: R) -> (R, R.Generator.Element) { - return removeAtIndex(collection, i) +public func removeAtIndex(i: R.Index, collection: R) -> (R, R.Generator.Element) { + return removeAtIndex(collection, i: i) } -public func removeRange(var collection: R, subRange: Range) -> R { - collection.removeRange(subRange) - return collection +public func removeRange( collection: R, subRange: Range) -> R { + var c = collection + c.removeRange(subRange) + return c } -public func removeRange(subRange: Range)(collection: R) -> R { - return removeRange(collection, subRange) +public func removeRange(subRange: Range, collection: R) -> R { + return removeRange(collection, subRange: subRange) } // // MARK: MutableCollectionType // -public func replace(var collection: C, newElement: C.Generator.Element, atIndex i: C.Index) -> C { - collection[i] = newElement - return collection +public func replace( collection: C, newElement: C.Generator.Element, atIndex i: C.Index) -> C { + var c = collection + c[i] = newElement + return c } -public func replace(newElement: C.Generator.Element, atIndex i: C.Index)(collection: C) -> C { - return replace(collection, newElement, atIndex: i) +public func replace(newElement: C.Generator.Element, atIndex i: C.Index, collection: C) -> C { + return replace(collection, newElement: newElement, atIndex: i) } // @@ -113,8 +121,9 @@ public func replace(newElement: C.Generator.Element, a /// /// Returns the new dictionary, and the value that was replaced, or `nil` if a new key-value pair /// was added. -public func updateValue(var dictionary: [T:U], value: U, forKey key: T) -> ([T:U], oldValue: U?) { - let result = dictionary.updateValue(value, forKey: key) +public func updateValue( dictionary: [T:U], value: U, forKey key: T) -> ([T:U], oldValue: U?) { + var d = dictionary + let result = d.updateValue(value, forKey: key) return (dictionary, result) } @@ -123,8 +132,8 @@ public func updateValue(var dictionary: [T:U], value: U, forKey key: T) -> /// /// Returns the new dictionary, and the value that was replaced, or `nil` if a new key-value pair /// was added. -public func updateValue(value: U, forKey key: T)(dictionary: [T:U]) -> ([T:U], oldValue: U?) { - return updateValue(dictionary, value, forKey: key) +public func updateValue(value: U, forKey key: T, dictionary: [T:U]) -> ([T:U], oldValue: U?) { + return updateValue(dictionary, value: value, forKey: key) } /// Returns the `Index` for the given key, or `nil` if the key is not @@ -135,37 +144,39 @@ public func getValue(dictionary: [T:U], forKey key: T) -> U? { /// Returns the `Index` for the given key, or `nil` if the key is not /// present in the dictionary. -public func getValue(forKey key: T)(dictionary: [T:U]) -> U? { +public func getValue(forKey key: T, dictionary: [T:U]) -> U? { return dictionary[key] } /// Puts the given `value` under `key` in `dictionary` unless `key` already exists. -public func putNewValue(var dictionary: [T:U], value: U, forKey key: T) -> [T:U] { +public func putNewValue( dictionary: [T:U], value: U, forKey key: T) -> [T:U] { if let _ = dictionary[key] { return dictionary } else { - dictionary[key] = value - return dictionary + var d = dictionary + d[key] = value + return d } } /// Puts the given `value` under `key` in `dictionary` unless `key` already exists. -public func putNewValue(value: U, forKey key: T)(dictionary: [T:U]) -> [T:U] { - return putNewValue(dictionary, value, forKey: key) +public func putNewValue(value: U, forKey key: T, dictionary: [T:U]) -> [T:U] { + return putNewValue(dictionary, value: value, forKey: key) } /// Remove a given key and the associated value from the dictionary. /// Returns the updated dictionary and value that was removed, or `nil` if the key was not present /// in the dictionary. -public func removeValueForKey(var dictionary: [T:U], key: T) -> ([T:U], removed: U?) { - let result = dictionary.removeValueForKey(key) - return (dictionary, result) +public func removeValueForKey( dictionary: [T:U], key: T) -> ([T:U], removed: U?) { + var d = dictionary + let result = d.removeValueForKey(key) + return (d, result) } /// Remove a given key and the associated value from the dictionary. /// Returns the updated dictionary and value that was removed, or `nil` if the key was not present /// in the dictionary. -public func removeValueForKey(key: T)(dictionary: [T:U]) -> ([T:U], removed: U?) { - return removeValueForKey(dictionary, key) +public func removeValueForKey(key: T, dictionary: [T:U]) -> ([T:U], removed: U?) { + return removeValueForKey(dictionary, key: key) } \ No newline at end of file diff --git a/PipesTests/BackwardPipeTests.swift b/PipesTests/BackwardPipeTests.swift index 71c8e40..b18354b 100644 --- a/PipesTests/BackwardPipeTests.swift +++ b/PipesTests/BackwardPipeTests.swift @@ -9,7 +9,7 @@ class BackwardPipeTests : XCTestCase { func testPipeOperatorWorks() { let increment: Int->Int = { x in x + 1 } let value = increment <| 4 - expect(value) == 5 + XCTAssertEqual(value, 5) } func testOrderOfOperations() { @@ -17,9 +17,9 @@ class BackwardPipeTests : XCTestCase { let double: Int->Int = {x in x*2} var value = double <| 2 + 4 - expect(value) == 12 + XCTAssertEqual(value, 12) value = double <| increment <| 2 - expect(value) == 6 + XCTAssertEqual(value, 6) } } diff --git a/PipesTests/ForwardPipeTests.swift b/PipesTests/ForwardPipeTests.swift index fb259cc..6a37f41 100644 --- a/PipesTests/ForwardPipeTests.swift +++ b/PipesTests/ForwardPipeTests.swift @@ -7,25 +7,28 @@ import Foundation import XCTest import Pipes import Result -import Box + +enum TestError: ErrorType { + case NotEven +} class FowardPipeTests : XCTestCase { func testFirstArgumentPipe() { let f: (Int, Int, Int) -> Int = { x, _, _ in x } - var value = 1 |> (f, 2, 3) - expect(value) == 1 + let value = 1 |> (f, 2, 3) + XCTAssertEqual(value, 1) } func testSecondArgumentPipe() { let f: (Int, Int, Int) -> Int = { _, x, _ in x } - var value = 2 |>> (f, 1, 3) - expect(value) == 2 + let value = 2 |>> (f, 1, 3) + XCTAssertEqual(value, 2) } func testThirdArgument() { let f: (Int, Int, Int) -> Int = { $2 } - var value = 3 |>>> (f, 1, 2) - expect(value) == 3 + let value = 3 |>>> (f, 1, 2) + XCTAssertEqual(value, 3) } func testLastArgumentPipe() { @@ -34,10 +37,10 @@ class FowardPipeTests : XCTestCase { let f3: (Int, Int, Int) -> Int = { $2 } let f4: (Int, Int, Int, Int) -> Int = { $3 } - expect(1 |< f1) == 1 - expect(2 |< (f2, 1)) == 2 - expect(3 |< (f3, 1, 2)) == 3 - expect(4 |< (f4, 1, 2, 3)) == 4 + XCTAssertEqual(1 |< f1, 1) + XCTAssertEqual(2 |< (f2, 1), 2) + XCTAssertEqual(3 |< (f3, 1, 2), 3) + XCTAssertEqual(4 |< (f4, 1, 2, 3), 4) } func testOrderOfOperations() { @@ -45,36 +48,35 @@ class FowardPipeTests : XCTestCase { let double: Int->Int = {x in x*2} var value = 2 + 4 |> double - expect(value) == 12 + XCTAssertEqual(value, 12) value = 2 |> increment |> double - expect(value) == 6 + XCTAssertEqual(value, 6) } func testResultPipe() { - let even: Int -> Result = { x in + let even: Int -> Result = { x in if x % 2 == 0 { - return .Success(Box(x)) + return .Success(x) } else { - return .Failure(Box("not even")) + return .Failure(TestError.NotEven) } } var result = 2 |> even switch result { - case let .Success(valueBox): - let value = valueBox.value - expect(value) == 2 - case let .Failure(message): + case let .Success(value): + XCTAssertEqual(value, 2) + case .Failure: XCTFail("should not have failed") } result = 3 |> even switch result { - case let .Success: + case .Success: XCTFail("pipe should have short circuited") case .Failure: break diff --git a/PipesTests/Info.plist b/PipesTests/Info.plist index 3282925..ba72822 100644 --- a/PipesTests/Info.plist +++ b/PipesTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - me.jasonlarsen.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/PipesTests/TestHelpers.swift b/PipesTests/TestHelpers.swift deleted file mode 100644 index f289ab3..0000000 --- a/PipesTests/TestHelpers.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// Created by Jason Larsen on 4/27/15. -// - -import XCTest - -func expect(value: T, file: String = __FILE__, line: Int = __LINE__) -> (T, String, Int) { - return (value, file, line) -} - -func ==(lhs: (T, String, Int), rhs: T) { - if lhs.0 != rhs { - XCTFail("Expected \(rhs), but got \(lhs.0) instead", file: lhs.1, line: UInt(lhs.2)) - } -} - -func !=(lhs: (T, String, Int), rhs: T) { - if lhs.0 == rhs { - XCTFail("Expected \(rhs), but got \(lhs.0) instead", file: lhs.1, line: UInt(lhs.2)) - } -} \ No newline at end of file From a639f57e5396a7b005b3e0124872743589c751d1 Mon Sep 17 00:00:00 2001 From: Greg Pardo Date: Thu, 24 Mar 2016 15:13:52 -0400 Subject: [PATCH 2/2] Opps remove unecessary architechtures --- Cartfile.resolved | 2 +- Pipes.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 4bab36a..861bb5e 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "antitypical/Result" "89653c28708641d428b447bb5f3cbc69173ab8cb" +github "antitypical/Result" "96970bf1a00a8b0c171716652070c6f8301829b4" diff --git a/Pipes.xcodeproj/project.pbxproj b/Pipes.xcodeproj/project.pbxproj index 01f1206..204b518 100644 --- a/Pipes.xcodeproj/project.pbxproj +++ b/Pipes.xcodeproj/project.pbxproj @@ -412,7 +412,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - VALID_ARCHS = "arm64 armv7 armv7s x86_64 i386"; + VALID_ARCHS = "arm64 armv7 armv7s"; }; name = Debug; }; @@ -435,7 +435,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "me.jasonlarsen.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - VALID_ARCHS = "arm64 armv7 armv7s x86_64 i386"; + VALID_ARCHS = "arm64 armv7 armv7s"; }; name = Release; };