Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST PULL REQUEST don't merge #40

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 25 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
language: objective-c
osx_image: xcode8
xcode_project: Promise.xcodeproj
xcode_scheme: Promise
xcode_sdk: iphonesimulator10.0
language: generic
matrix:
include:
- os: linux
dist: trusty
sudo: required
- os: osx
osx_image: xcode9.2
addons:
apt:
packages:
- clang
- pkg-config
install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then SWIFT_DIR=tests ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir $SWIFT_DIR ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl https://swift.org/builds/swift-4.0.3-release/ubuntu1404/swift-4.0.3-RELEASE/swift-4.0.3-RELEASE-ubuntu14.04.tar.gz -s | tar xz -C $SWIFT_DIR &> /dev/null ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install clang libicu-dev ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then xcodebuild -showsdks ; fi
env:
- SWIFT_VERSION=swift-4.0.3-RELEASE
script:
- set -o pipefail && xcodebuild -project Promise.xcodeproj -scheme Promise -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=10.0,name=iPhone SE' build test | xcpretty
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export PATH=$(pwd)/tests/$SWIFT_VERSION-ubuntu14.04/usr/bin:"${PATH}" ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then swift test ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then xcodebuild clean test -scheme Promise -destination 'platform=iOS Simulator,name=iPhone SE,OS=latest' ; fi
17 changes: 17 additions & 0 deletions LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import XCTest
@testable import PromiseTests

XCTMain([
testCase(ExecutionContextTests.allTests),
testCase(PromiseAllTests.allTests),
testCase(PromiseAlwaysTests.allTests),
testCase(PromiseDelayTests.allTests),
testCase(PromiseEnsureTests.allTests),
testCase(PromiseKickoffTests.allTests),
testCase(PromiseRaceTests.allTests),
testCase(PromiseRecoverTests.allTests),
testCase(PromiseRetryTests.allTests),
testCase(PromiseTests.allTests),
testCase(PromiseThrowsTests.allTests),
testCase(PromiseZipTests.allTests),
])
23 changes: 14 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ import PackageDescription
let package = Package(
name: "Promises",
products: [
.library(
name: "Promise",
targets: ["Promise"]
),
.library(
name: "Promise",
targets: ["Promise"]
),
],
dependencies: [],
targets: [
.target(
name: "Promise",
dependencies: [],
path: "Promise"
)
.target(
name: "Promise",
dependencies: [],
path: "Promise"
),
.testTarget(
name: "PromiseTests",
dependencies: ["Promise"],
path: "PromiseTests"
)
]
)
11 changes: 11 additions & 0 deletions PromiseTests/ExecutionContextTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import XCTest

import Promise

#if os(Linux)
import Dispatch
#endif

class ExecutionContextTests: XCTestCase {


Expand Down Expand Up @@ -94,4 +98,11 @@ class ExecutionContextTests: XCTestCase {

}


static let allTests = [
("testNonInvalidatedInvalidatableQueue", testNonInvalidatedInvalidatableQueue),
("testInvalidatedInvalidatableQueue", testInvalidatedInvalidatableQueue),
("testTapContinuesToFireInvalidatableQueue", testTapContinuesToFireInvalidatableQueue),
("testInvalidatableQueueSupportsNonMainQueues", testInvalidatableQueueSupportsNonMainQueues),
]
}
8 changes: 7 additions & 1 deletion PromiseTests/PromiseAllTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,11 @@ class PromiseAllTests: XCTestCase {
XCTAssert(final.isRejected)
}


static let allTests = [
("testAll", testAll),
("testAllWithPreFulfilledValues", testAllWithPreFulfilledValues),
("testAllWithEmptyArray", testAllWithEmptyArray),
("testAllWithRejectionHappeningFirst", testAllWithRejectionHappeningFirst),
("testAllWithRejectionHappeningLast", testAllWithRejectionHappeningLast),
]
}
23 changes: 15 additions & 8 deletions PromiseTests/PromiseAlwaysTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class PromiseAlwaysTests: XCTestCase {
}
})

promise.always({ _ in
promise.always {
expectation?.fulfill()
})
}

waitForExpectations(timeout: 1, handler: nil)
XCTAssert(promise.isFulfilled)
Expand All @@ -37,9 +37,9 @@ class PromiseAlwaysTests: XCTestCase {
}
})

promise.always({ _ in
promise.always {
expectation?.fulfill()
})
}

waitForExpectations(timeout: 1, handler: nil)
XCTAssert(promise.isRejected)
Expand All @@ -50,9 +50,9 @@ class PromiseAlwaysTests: XCTestCase {

let promise = Promise(value: 5)

promise.always({ _ in
promise.always {
expectation?.fulfill()
})
}

waitForExpectations(timeout: 1, handler: nil)
XCTAssert(promise.isFulfilled)
Expand All @@ -63,12 +63,19 @@ class PromiseAlwaysTests: XCTestCase {

let promise = Promise<Int>(error: SimpleError())

promise.always({ _ in
promise.always {
expectation?.fulfill()
})
}

waitForExpectations(timeout: 1, handler: nil)
XCTAssert(promise.isRejected)
}


static let allTests = [
("testAlways", testAlways),
("testAlwaysRejects", testAlwaysRejects),
("testAlwaysInstantFulfill", testAlwaysInstantFulfill),
("testAlwaysInstantReject", testAlwaysInstantReject),
]
}
7 changes: 7 additions & 0 deletions PromiseTests/PromiseDelayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,11 @@ class PromiseDelayTests: XCTestCase {
waitForExpectations(timeout: 1, handler: nil)
XCTAssert(promise.isRejected)
}

static let allTests = [
("testDelay", testDelay),
("testTimeoutPromise", testTimeoutPromise),
("testTimeoutFunctionSucceeds", testTimeoutFunctionSucceeds),
("testTimeoutFunctionFails", testTimeoutFunctionFails),
]
}
5 changes: 5 additions & 0 deletions PromiseTests/PromiseEnsureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ class PromiseEnsureTests: XCTestCase {
XCTAssertNotNil(promise.error)
}

static let allTests = [
("testEnsureRejects", testEnsureRejects),
("testEnsureSucceeds", testEnsureSucceeds),
("testEnsureOnlyCalledOnSucceess", testEnsureOnlyCalledOnSucceess),
]
}
4 changes: 4 additions & 0 deletions PromiseTests/PromiseKickoffTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ class PromiseKickoffTests: XCTestCase {
XCTAssert(promise.isRejected)
}

static let allTests = [
("testKickoff", testKickoff),
("testFailingKickoff", testFailingKickoff),
]
}
6 changes: 6 additions & 0 deletions PromiseTests/PromiseRaceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@ class PromiseRaceTests: XCTestCase {
XCTAssert(final.isRejected)
}

static let allTests = [
("testRace", testRace),
("testRaceFailure", testRaceFailure),
("testInstantResolve", testInstantResolve),
("testInstantReject", testInstantReject),
]
}
9 changes: 9 additions & 0 deletions PromiseTests/PromiseRecoverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,13 @@ class PromiseRecoverTests: XCTestCase {
XCTAssertEqual(int, 2)
XCTAssert(promise.isFulfilled)
}

static let allTests = [
("testRecover", testRecover),
("testRecoverWithThrowingFunction", testRecoverWithThrowingFunction),
("testRecoverWithThrowingFunctionError", testRecoverWithThrowingFunctionError),
("testRecoverInstant", testRecoverInstant),
("testIgnoreRecover", testIgnoreRecover),
("testIgnoreRecoverInstant", testIgnoreRecoverInstant),
]
}
6 changes: 6 additions & 0 deletions PromiseTests/PromiseRetryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@ class PromiseRetryTests: XCTestCase {
waitForExpectations(timeout: 1, handler: nil)
XCTAssert(promise.isRejected)
}

static let allTests = [
("testRetry", testRetry),
("testRetryWithInstantSuccess", testRetryWithInstantSuccess),
("testRetryWithNeverSuccess", testRetryWithNeverSuccess),
]
}
20 changes: 20 additions & 0 deletions PromiseTests/PromiseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,24 @@ class PromiseTests: XCTestCase {
promise.reject(SimpleError())
XCTAssertEqual(promise.value, "correct")
}

static let allTests = [
("testThen", testThen),
("testAsync", testAsync),
("testAsyncThrowing", testAsyncThrowing),
("testAsyncRejection", testAsyncRejection),
("testThenWhenPending", testThenWhenPending),
("testRejectedAfterFulfilled", testRejectedAfterFulfilled),
("testPending", testPending),
("testFulfilled", testFulfilled),
("testRejected", testRejected),
("testMap", testMap),
("testFlatMap", testFlatMap),
("testTrailingClosuresCompile", testTrailingClosuresCompile),
("testZalgoContained", testZalgoContained),
("testDoubleResolve", testDoubleResolve),
("testRejectThenResolve", testRejectThenResolve),
("testDoubleReject", testDoubleReject),
("testResolveThenReject", testResolveThenReject),
]
}
6 changes: 6 additions & 0 deletions PromiseTests/PromiseThrowsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@ class PromiseThrowsTests: XCTestCase {
XCTAssert(promise.error is SimpleError)
}

static let allTests = [
("testThrowsInMapping", testThrowsInMapping),
("testThrowsInMappingWithError", testThrowsInMappingWithError),
("testThrowsInFlatmapping", testThrowsInFlatmapping),
("testThrowsInFlatmappingWithError", testThrowsInFlatmappingWithError),
]
}
5 changes: 5 additions & 0 deletions PromiseTests/PromiseZipTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ class PromiseZipTests: XCTestCase {
XCTAssertEqual(tuple.2, [1, 1, 2, 3, 5])
XCTAssertEqual(tuple.3, ["two", "strings"])
}

static let allTests = [
("testZipping2", testZipping2),
("testMultipleParameters", testMultipleParameters),
]
}
3 changes: 3 additions & 0 deletions PromiseTests/delay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

import XCTest
#if os(Linux)
import Dispatch
#endif

internal func delay(_ duration: TimeInterval, block: @escaping () -> ()) {
DispatchQueue.main.asyncAfter(deadline: .now() + duration, execute: {
Expand Down