Skip to content

Commit

Permalink
Bumps to 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
s4cha committed Jan 3, 2018
1 parent 234ee5a commit 77831b6
Show file tree
Hide file tree
Showing 27 changed files with 65 additions and 66 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![codebeat badge](https://codebeat.co/badges/768d3017-1e65-47e0-b287-afcb8954a1da)](https://codebeat.co/projects/github-com-s4cha-then)
[![Join the chat at https://gitter.im/s4cha/then](https://badges.gitter.im/s4cha/then.svg)](https://gitter.im/s4cha/then?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![License: MIT](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)](https://github.com/freshOS/then/blob/master/LICENSE)
[![Release version](https://img.shields.io/badge/release-2.2-blue.svg)]()
tag](https://img.shields.io/github/release/freshos/then.svg)]()

[Reason](#why) - [Example](#example) - [Documentation](#documentation) - [Installation](#installation)

Expand Down Expand Up @@ -391,14 +391,14 @@ Grab this repository and build the Framework target on the example project. Then
## Swift Version
Swift 2 -> version **1.4.2**
Swift 3 -> version **2.2.5**
Swift 4 -> version **3.0.1**
Swift 4 -> version **3.0.2**

<!-- Place this tag in your head or just before your close body tag. -->
<script async defer src="https://buttons.github.io/buttons.js"></script>


### Backers
Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)
Like the project? Offer coffee or support us with a monthly donation and help us continue our activities :)

<a href="https://opencollective.com/freshos/backer/0/website" target="_blank"><img src="https://opencollective.com/freshos/backer/0/avatar.svg"></a>
<a href="https://opencollective.com/freshos/backer/1/website" target="_blank"><img src="https://opencollective.com/freshos/backer/1/avatar.svg"></a>
Expand Down Expand Up @@ -432,7 +432,7 @@ Like the project? Offer coffee or support us with a monthly donation and help us
<a href="https://opencollective.com/freshos/backer/29/website" target="_blank"><img src="https://opencollective.com/freshos/backer/29/avatar.svg"></a>

### Sponsors
Become a sponsor and get your logo on our README on Github with a link to your site :)
Become a sponsor and get your logo on our README on Github with a link to your site :)

<a href="https://opencollective.com/freshos/sponsor/0/website" target="_blank"><img src="https://opencollective.com/freshos/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/freshos/sponsor/1/website" target="_blank"><img src="https://opencollective.com/freshos/sponsor/1/avatar.svg"></a>
Expand Down
2 changes: 1 addition & 1 deletion Source/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0.1</string>
<string>3.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions Source/Promise+Recover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension Promise {
syncStateWithCallBacks(
success: p.fulfill,
failure: { e in
if errorMatchesExpectedError(e, expectedError:errorType) {
if errorMatchesExpectedError(e, expectedError: errorType) {
p.fulfill(value)
} else {
p.reject(e)
Expand All @@ -40,7 +40,7 @@ extension Promise {
syncStateWithCallBacks(
success: p.fulfill,
failure: { e in
if errorMatchesExpectedError(e, expectedError:errorType) {
if errorMatchesExpectedError(e, expectedError: errorType) {
p.fulfill(value)
} else {
p.reject(e)
Expand Down
2 changes: 1 addition & 1 deletion Source/Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public class Promise<T> {
}

internal func reject(_ anError: Error) {
updateState(PromiseState<T>.rejected(error: anError))
updateState(PromiseState<T>.rejected(error: anError))
// Only release callbacks if no retries a registered.
if numberOfRetries == 0 {
blocks = PromiseBlocks<T>()
Expand Down
2 changes: 1 addition & 1 deletion Source/PromiseError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public func == (lhs: PromiseError, rhs: PromiseError) -> Bool {
return true
case (.raceAllFailed, .raceAllFailed):
return true
case (.unwrappingFailed, .unwrappingFailed):
case (.unwrappingFailed, .unwrappingFailed):
return true
default:
return false
Expand Down
16 changes: 8 additions & 8 deletions Source/WhenAll.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Promises {}

extension Promises {

public static func whenAll<T>(_ promises: [Promise<T>]) -> Promise<[T]> {
public static func whenAll<T>(_ promises: [Promise<T>], callbackQueue: DispatchQueue? = nil) -> Promise<[T]> {
let p = Promise<[T]>()
var ts = [T]()
var error: Error?
Expand All @@ -25,7 +25,7 @@ extension Promises {
.finally { group.leave() }
}
let callingQueue = OperationQueue.current?.underlyingQueue
let queue = callingQueue ?? DispatchQueue.main
let queue = callbackQueue ?? callingQueue ?? DispatchQueue.main
group.notify(queue: queue) {
if let e = error {
p.reject(e)
Expand All @@ -36,13 +36,13 @@ extension Promises {
return p
}

public static func whenAll<T>(_ promises: Promise<T>...) -> Promise<[T]> {
return whenAll(promises)
public static func whenAll<T>(_ promises: Promise<T>..., callbackQueue: DispatchQueue? = nil) -> Promise<[T]> {
return whenAll(promises, callbackQueue: callbackQueue)
}

// Array version

public static func whenAll<T>(_ promises: [Promise<[T]>]) -> Promise<[T]> {
public static func whenAll<T>(_ promises: [Promise<[T]>], callbackQueue: DispatchQueue? = nil) -> Promise<[T]> {
let p = Promise<[T]>()
var ts = [T]()
var error: Error?
Expand All @@ -54,7 +54,7 @@ extension Promises {
.finally { group.leave() }
}
let callingQueue = OperationQueue.current?.underlyingQueue
let queue = callingQueue ?? DispatchQueue.main
let queue = callbackQueue ?? callingQueue ?? DispatchQueue.main
group.notify(queue: queue) {
if let e = error {
p.reject(e)
Expand All @@ -65,7 +65,7 @@ extension Promises {
return p
}

public static func whenAll<T>(_ promises: Promise<[T]>...) -> Promise<[T]> {
return whenAll(promises)
public static func whenAll<T>(_ promises: Promise<[T]>..., callbackQueue: DispatchQueue? = nil) -> Promise<[T]> {
return whenAll(promises, callbackQueue: callbackQueue)
}
}
Binary file modified then.framework.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion thenMacOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0.1</string>
<string>3.0.2</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion thenPromise.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'thenPromise'
s.version = "3.0.1"
s.version = "3.0.2"
s.summary = "Elegant Promises for Swift"
s.homepage = "https://github.com/freshOS/then"
s.license = { :type => "MIT", :file => "LICENSE" }
Expand Down
4 changes: 2 additions & 2 deletions thenTests/AsyncAwaitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AsyncAwaitTests: XCTestCase {
let exp = expectation(description: "")
async {
_ = try await(failingFetchUserFollowStatusFromName("JohnDoe"))
XCTFail()
XCTFail("testFailingAsyncAwait failed")
}.onError { _ in
exp.fulfill()
}
Expand All @@ -40,7 +40,7 @@ class AsyncAwaitTests: XCTestCase {
let exp = expectation(description: "")
do {
_ = try await(failingFetchUserFollowStatusFromName("JohnDoe"))
XCTFail()
XCTFail("testCatchFailingAsyncAwait failed")
} catch {
exp.fulfill()
}
Expand Down
8 changes: 4 additions & 4 deletions thenTests/BridgeErrorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BridgeErrorTests: XCTestCase {
if let e = e as? MyError {
XCTAssertTrue(e == .defaultError)
} else {
XCTFail()
XCTFail("testBridgeAllErrorsToMine failed")
}
exp.fulfill()
}
Expand Down Expand Up @@ -51,7 +51,7 @@ class BridgeErrorTests: XCTestCase {
if let e = e as? MyError {
XCTAssertTrue(e == .defaultError)
} else {
XCTFail()
XCTFail("testBridgeASpecificErrorToMine failed")
}
exp.fulfill()
}
Expand All @@ -68,7 +68,7 @@ class BridgeErrorTests: XCTestCase {
if let e = e as? PromiseError {
XCTAssertTrue(e == .default)
} else {
XCTFail()
XCTFail("testBridgeASpecificErrorToMineNotMatchingError failed")
}
exp.fulfill()
}
Expand All @@ -87,7 +87,7 @@ class BridgeErrorTests: XCTestCase {
if let e = e as? MyError {
XCTAssertTrue(e == .defaultError)
} else {
XCTFail()
XCTFail("failed testBridgeErrorCanUseBlockAndThrow")
}
exp.fulfill()
}
Expand Down
4 changes: 2 additions & 2 deletions thenTests/ChainTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ChainTests: XCTestCase {
func testChainNotCalledWhenSyncPromiseFails() {
let exp = expectation(description: "")
Promise<Int>.reject().chain { _ in
XCTFail()
XCTFail("testChainNotCalledWhenSyncPromiseFails failed")
}.onError { _ in
exp.fulfill()
}
Expand All @@ -42,7 +42,7 @@ class ChainTests: XCTestCase {
func testChainNotCalledWhenAsyncPromiseFails() {
let exp = expectation(description: "")
failingFetchUserFollowStatusFromName("Tom").chain { _ in
XCTFail()
XCTFail("testChainNotCalledWhenAsyncPromiseFails failed")
}.onError { _ in
exp.fulfill()
}
Expand Down
2 changes: 1 addition & 1 deletion thenTests/DelayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class DelayTests: XCTestCase {
reject(PromiseError.default)
}
}.delay(0.8).then { _ in
XCTFail()
XCTFail("testDelayOnlyAppliesOnSuccessfulPromises failed")
}.onError { _ in
done = true
e.fulfill()
Expand Down
2 changes: 1 addition & 1 deletion thenTests/FinallyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class FinallyTests: XCTestCase {
func testRegisterFinallyDoesntStartThePromise() {
let exp = expectation(description: "error block called")
syncRejectionPromise().registerFinally {
XCTFail()
XCTFail("testRegisterFinallyDoesntStartThePromise failed")
}
waitTime(1) {
exp.fulfill()
Expand Down
2 changes: 1 addition & 1 deletion thenTests/OnErrorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class OnErrorTests: XCTestCase {
func testRegisterOnErrorDoesntStartThePromise() {
let exp = expectation(description: "error block called")
syncRejectionPromise().registerOnError { _ in
XCTFail()
XCTFail("testRegisterOnErrorDoesntStartThePromise failed")
}
waitTime(1) {
exp.fulfill()
Expand Down
2 changes: 1 addition & 1 deletion thenTests/ProgressTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ProgressTests: XCTestCase {
XCTAssertEqual(p, 0.8)
progressExpectation.fulfill()
}.then {
XCTFail()
XCTFail("testProgressFails failed")
}.onError { _ in
errorExpectation.fulfill()
}
Expand Down
2 changes: 1 addition & 1 deletion thenTests/RaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RaceTests: XCTestCase {
let p1 = Promise<String>.reject()
let p2 = Promise<String>.reject()
Promises.race(p1, p2).then { _ in
XCTFail()
XCTFail("testRaceFailsIfAllFail failed")
}.onError { _ in
e.fulfill()
}
Expand Down
6 changes: 3 additions & 3 deletions thenTests/RecoverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RecoverTests: XCTestCase {
if let e = e as? MyError {
XCTAssertTrue(e == .defaultError)
} else {
XCTFail()
XCTFail("testRecoverCanThrowANewError failed")
}
exp.fulfill()
}
Expand All @@ -108,7 +108,7 @@ class RecoverTests: XCTestCase {
Promise<Int>.reject()
.recover(PromiseError.validationFailed, with: 123)
.then { _ in
XCTFail()
XCTFail("testRecoverForSpecificErrorDoesNotRecoverWhenTypeNotMatching failed")
}.onError { _ in
exp.fulfill()
}
Expand All @@ -127,7 +127,7 @@ class RecoverTests: XCTestCase {
}

struct SomeError: Error { }
extension SomeError :Equatable { }
extension SomeError: Equatable { }
func == (lhs: SomeError, rhs: SomeError) -> Bool {
return true
}
23 changes: 11 additions & 12 deletions thenTests/RegisterThenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class RegisterThenTests: XCTestCase {
let timerExpectation = expectation(description: "timerExpectation")
fetchUserId()
.registerThen { _ in
XCTFail()
XCTFail("testRegisterThenChainedPromisesAreNeverCalledWithoutAThenBlock failed")
}.registerThen {_ in
XCTFail()
XCTFail("testRegisterThenChainedPromisesAreNeverCalledWithoutAThenBlock failed")
}.registerThen {_ in
XCTFail()
XCTFail("testRegisterThenChainedPromisesAreNeverCalledWithoutAThenBlock failed")
}
waitTime(1) {
timerExpectation.fulfill()
Expand All @@ -32,11 +32,11 @@ class RegisterThenTests: XCTestCase {
fetchUserId()
.registerThen(fetchUserNameFromId(10)).registerThen { name in
print(name)
XCTFail()
XCTFail("testRegisterThenPromiseChainedPromisesAreNeverCalledWithoutAThenBlock failed")
}.registerThen {_ in
XCTFail()
XCTFail("testRegisterThenPromiseChainedPromisesAreNeverCalledWithoutAThenBlock failed")
}.registerThen {_ in
XCTFail()
XCTFail("testRegisterThenPromiseChainedPromisesAreNeverCalledWithoutAThenBlock failed")
}
waitTime(1) {
timerExpectation.fulfill()
Expand All @@ -48,11 +48,10 @@ class RegisterThenTests: XCTestCase {
let timerExpectation = expectation(description: "timerExpectation")
fetchUserId().registerThen { id in
return fetchUserNameFromId(id)
}.registerThen { name in
print(name)
XCTFail()
}.registerThen { _ in
XCTFail()
XCTFail("testRegisterThenPromise2ChainedPromisesAreNeverCalledWithoutAThenBlock failed")
}.registerThen { _ in
XCTFail("testRegisterThenPromise2ChainedPromisesAreNeverCalledWithoutAThenBlock failed")
}
waitTime(1) {
timerExpectation.fulfill()
Expand Down Expand Up @@ -95,7 +94,7 @@ class RegisterThenTests: XCTestCase {
fetchUserId()
.registerThen(fetchUserNameFromId)
.registerThen { _ in
XCTFail()
XCTFail("testRegisterThenPromiseFuncPointerNotCalled failed")
}
waitTime(1) {
timerExpectation.fulfill()
Expand All @@ -108,7 +107,7 @@ class RegisterThenTests: XCTestCase {
fetchUserId().registerThen { id -> Promise<String> in
return fetchUserNameFromId(id)
}.registerThen { _ in
XCTFail()
XCTFail("testRegisterThenPromise2FuncPointerNotCalled failed")
}
waitTime(1) {
timerExpectation.fulfill()
Expand Down
4 changes: 2 additions & 2 deletions thenTests/RetryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RetryTests: XCTestCase {
let e = expectation(description: "")
testPromise()
.retry(5).then {
XCTFail()
XCTFail("testRetryNumberWhenKeepsFailing failed")
}.onError { _ in
e.fulfill()
XCTAssertEqual(5, self.tryCount)
Expand All @@ -32,7 +32,7 @@ class RetryTests: XCTestCase {
e.fulfill()
XCTAssertEqual(3, self.tryCount)
}.onError { _ in
XCTFail()
XCTFail("testRetrySucceedsAfter3times failed")
}
waitForExpectations(timeout: 1, handler: nil)
}
Expand Down
2 changes: 1 addition & 1 deletion thenTests/ThenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ThenTests: XCTestCase {
let thenExpectation = expectation(description: "then called")
let errorExpectation = expectation(description: "Finally called")
failingFetchUserFollowStatusFromName("").then { _ in
XCTFail()
XCTFail("testCanContinueWithThenAfterErrorBlock failed")
}.onError { _ in
errorExpectation.fulfill()
}.then {
Expand Down
Loading

0 comments on commit 77831b6

Please sign in to comment.