Skip to content

Commit

Permalink
Merge pull request #824 from Quick/fix-swift-5.3-incompatibility-of-e…
Browse files Browse the repository at this point in the history
…xpect

[API BREAKING] Modify `expect` overloads to fix Swift 5.3 incompatibility
  • Loading branch information
ikesyo authored Sep 17, 2020
2 parents 842704d + e884b4f commit 428d6d1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
xcode: [11.7]
platform: [macos, ios, tvos, macos_xcodespm, ios_xcodespm, tvos_xcodespm]
xcode: [11.7, 12]
platform: [macos, ios, tvos]
fail-fast: false
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app
steps:
- uses: actions/checkout@v2
- run: ./test ${{ matrix.platform }}
- run: ./test ${{ matrix.platform }}_xcodespm

swiftpm_darwin:
name: SwiftPM, Darwin, Xcode ${{ matrix.xcode }}
runs-on: macos-latest
strategy:
matrix:
xcode: [11.7]
xcode: [11.7, 12]
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app
steps:
Expand Down
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ jobs:
# osx_image: xcode10.3
# script: ./test swiftpm
- &swiftpm_linux
name: SwiftPM / Linux / Swift 5.2.3
name: SwiftPM / Linux / Swift 5.2.5
os: linux
env:
- SWIFT_VERSION=5.2.3
- SWIFT_VERSION=5.2.5
install:
- eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
script:
- ./test swiftpm
- <<: *swiftpm_linux
name: SwiftPM / Linux / Swift 5.3 Development
env:
- SWIFT_VERSION=5.3-DEVELOPMENT-SNAPSHOT-2020-05-11-a
- SWIFT_VERSION=5.3-DEVELOPMENT-SNAPSHOT-2020-09-04-a
- <<: *swiftpm_linux
name: SwiftPM / Linux / Swift Development
env:
- SWIFT_VERSION=DEVELOPMENT-SNAPSHOT-2020-05-18-a
- SWIFT_VERSION=DEVELOPMENT-SNAPSHOT-2020-08-31-a
install: true
script:
- ./test $TYPE
Expand Down
4 changes: 1 addition & 3 deletions Sources/Nimble/Adapters/NMBExpectation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public class NMBExpectation: NSObject {
}

private var expectValue: Expectation<NSObject> {
return expect(_file, line: _line) {
self._actualBlock() as NSObject?
}
return expect(file: _file, line: _line, self._actualBlock() as NSObject?)
}

@objc public var withTimeout: (TimeInterval) -> NMBExpectation {
Expand Down
24 changes: 21 additions & 3 deletions Sources/Nimble/DSL.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Make an expectation on a given actual value. The value given is lazily evaluated.
public func expect<T>(_ expression: @autoclosure @escaping () throws -> T?, file: FileString = #file, line: UInt = #line) -> Expectation<T> {
public func expect<T>(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure @escaping () throws -> T?) -> Expectation<T> {
return Expectation(
expression: Expression(
expression: expression,
Expand All @@ -8,10 +8,28 @@ public func expect<T>(_ expression: @autoclosure @escaping () throws -> T?, file
}

/// Make an expectation on a given actual value. The closure is lazily invoked.
public func expect<T>(_ file: FileString = #file, line: UInt = #line, expression: @escaping () throws -> T?) -> Expectation<T> {
public func expect<T>(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() throws -> T)) -> Expectation<T> {
return Expectation(
expression: Expression(
expression: expression,
expression: expression(),
location: SourceLocation(file: file, line: line),
isClosure: true))
}

/// Make an expectation on a given actual value. The closure is lazily invoked.
public func expect<T>(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() throws -> T?)) -> Expectation<T> {
return Expectation(
expression: Expression(
expression: expression(),
location: SourceLocation(file: file, line: line),
isClosure: true))
}

/// Make an expectation on a given actual value. The closure is lazily invoked.
public func expect(file: FileString = #file, line: UInt = #line, _ expression: @autoclosure () -> (() throws -> Void)) -> Expectation<Void> {
return Expectation(
expression: Expression(
expression: expression(),
location: SourceLocation(file: file, line: line),
isClosure: true))
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/NimbleTests/Matchers/PostNotificationTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class PostNotificationTest: XCTestCase {
let bar = 2 as NSNumber
let n1 = Notification(name: Notification.Name("Foo"), object: foo)
let n2 = Notification(name: Notification.Name("Bar"), object: bar)
expect { () -> Void in
expect {
self.notificationCenter.post(n1)
self.notificationCenter.post(n2)
}.to(postNotifications(equal([n1, n2]), from: notificationCenter))
Expand Down Expand Up @@ -72,7 +72,7 @@ final class PostNotificationTest: XCTestCase {
let center = DistributedNotificationCenter()
let n1 = Notification(name: Notification.Name("Foo"), object: "1")
let n2 = Notification(name: Notification.Name("Bar"), object: "2")
expect { () -> Void in
expect {
center.post(n1)
center.post(n2)
}.toEventually(postDistributedNotifications(equal([n1, n2]), from: center, names: [n1.name, n2.name]))
Expand Down

0 comments on commit 428d6d1

Please sign in to comment.