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

[WIP] Swift 2.2 #243

Closed
wants to merge 3 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Sources/Nimble/DSL+Wait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private enum ErrorResult {
internal class NMBWait: NSObject {
internal class func until(
timeout timeout: NSTimeInterval,
file: String = __FILE__,
file: FileString = __FILE__,
line: UInt = __LINE__,
action: (() -> Void) -> Void) -> Void {
return throwableUntil(timeout: timeout, file: file, line: line) { (done: () -> Void) throws -> Void in
Expand All @@ -24,7 +24,7 @@ internal class NMBWait: NSObject {
// Using a throwable closure makes this method not objc compatible.
internal class func throwableUntil(
timeout timeout: NSTimeInterval,
file: String = __FILE__,
file: FileString = __FILE__,
line: UInt = __LINE__,
action: (() -> Void) throws -> Void) -> Void {
let awaiter = NimbleEnvironment.activeInstance.awaiter
Expand Down Expand Up @@ -71,7 +71,8 @@ internal class NMBWait: NSObject {
}

@objc(untilFile:line:action:)
internal class func until(file: String = __FILE__, line: UInt = __LINE__, action: (() -> Void) -> Void) -> Void {
internal class func until(file: FileString = __FILE__, line: UInt = __LINE__, action: (() -> Void) -> Void) -> Void {
// TODO: `StaticString` is not available in Objective-C!
until(timeout: 1, file: file, line: line, action: action)
}
}
Expand All @@ -87,7 +88,7 @@ internal func blockedRunLoopErrorMessageFor(fnName: String, leeway: NSTimeInterv
///
/// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function
/// is executing. Any attempts to touch the run loop may cause non-deterministic behavior.
public func waitUntil(timeout timeout: NSTimeInterval = 1, file: String = __FILE__, line: UInt = __LINE__, action: (() -> Void) -> Void) -> Void {
public func waitUntil(timeout timeout: NSTimeInterval = 1, file: FileString = __FILE__, line: UInt = __LINE__, action: (() -> Void) -> Void) -> Void {
NMBWait.until(timeout: timeout, file: file, line: line, action: action)
}
#endif
6 changes: 3 additions & 3 deletions Sources/Nimble/ObjCExpectation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ internal struct ObjCMatcherWrapper : Matcher {
public class NMBExpectation : NSObject {
internal let _actualBlock: () -> NSObject!
internal var _negative: Bool
internal let _file: String
internal let _file: FileString
internal let _line: UInt
internal var _timeout: NSTimeInterval = 1.0

public init(actualBlock: () -> NSObject!, negative: Bool, file: String, line: UInt) {
public init(actualBlock: () -> NSObject!, negative: Bool, file: FileString, line: UInt) {
self._actualBlock = actualBlock
self._negative = negative
self._file = file
Expand Down Expand Up @@ -123,7 +123,7 @@ public class NMBExpectation : NSObject {

public var toNotEventuallyWithDescription: (NMBMatcher, String) -> Void { return toEventuallyNotWithDescription }

public class func failWithMessage(message: String, file: String, line: UInt) {
public class func failWithMessage(message: String, file: FileString, line: UInt) {
fail(message, location: SourceLocation(file: file, line: line))
}
}
Expand Down
6 changes: 1 addition & 5 deletions Sources/Nimble/Utils/SourceLocation.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import Foundation

#if _runtime(_ObjC)
public typealias FileString = String
#else
public typealias FileString = StaticString
#endif

public class SourceLocation : NSObject {
public final class SourceLocation : NSObject {
public let file: FileString
public let line: UInt

Expand Down