Skip to content

Commit

Permalink
Try to fix the ambiguous use of expect on Swift 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesyo committed Sep 9, 2020
1 parent a5ed063 commit c16467d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
xcode: [11.7]
xcode: [12]
platform: [macos, ios, tvos, macos_xcodespm, ios_xcodespm, tvos_xcodespm]
fail-fast: false
env:
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
xcode: [11.7]
xcode: [12]
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app
steps:
Expand Down
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,18 @@ jobs:
# osx_image: xcode10.3
# script: ./test swiftpm
- &swiftpm_linux
name: SwiftPM / Linux / Swift 5.2.3
name: SwiftPM / Linux / Swift 5.3 Development
os: linux
env:
- SWIFT_VERSION=5.2.3
- SWIFT_VERSION=5.3-DEVELOPMENT-SNAPSHOT-2020-09-04-a
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
- <<: *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(self._actualBlock() as NSObject?, file: _file, line: _line)
}

@objc public var withTimeout: (TimeInterval) -> NMBExpectation {
Expand Down
15 changes: 12 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>(_ expression: @autoclosure @escaping () -> T?, file: FileString = #file, line: UInt = #line) -> Expectation<T> {
return Expectation(
expression: Expression(
expression: expression,
Expand All @@ -8,10 +8,19 @@ 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>(_ expression: @autoclosure () -> (() throws -> T), file: FileString = #file, line: UInt = #line) -> 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(_ expression: @autoclosure () -> (() throws -> Void), file: FileString = #file, line: UInt = #line) -> 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 c16467d

Please sign in to comment.