Skip to content

Swift 2.2 and Xcode 7.3 #269

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

Merged
merged 5 commits into from
Mar 24, 2016
Merged
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
osx_image: xcode7.2
osx_image: xcode7.3
language: generic
matrix:
include:
Expand Down
12 changes: 6 additions & 6 deletions Sources/Nimble/DSL+Wait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ private enum ErrorResult {
internal class NMBWait: NSObject {
internal class func until(
timeout timeout: NSTimeInterval,
file: FileString = __FILE__,
line: UInt = __LINE__,
file: FileString = #file,
line: UInt = #line,
action: (() -> Void) -> Void) -> Void {
return throwableUntil(timeout: timeout, file: file, line: line) { (done: () -> Void) throws -> Void in
action() { done() }
Expand All @@ -24,8 +24,8 @@ internal class NMBWait: NSObject {
// Using a throwable closure makes this method not objc compatible.
internal class func throwableUntil(
timeout timeout: NSTimeInterval,
file: FileString = __FILE__,
line: UInt = __LINE__,
file: FileString = #file,
line: UInt = #line,
action: (() -> Void) throws -> Void) -> Void {
let awaiter = NimbleEnvironment.activeInstance.awaiter
let leeway = timeout / 2.0
Expand Down Expand Up @@ -71,7 +71,7 @@ internal class NMBWait: NSObject {
}

@objc(untilFile:line:action:)
internal class func until(file: FileString = __FILE__, line: UInt = __LINE__, action: (() -> Void) -> Void) -> Void {
internal class func until(file: FileString = #file, line: UInt = #line, action: (() -> Void) -> Void) -> Void {
until(timeout: 1, file: file, line: line, action: action)
}
}
Expand All @@ -87,7 +87,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: FileString = __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
14 changes: 7 additions & 7 deletions Sources/Nimble/DSL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

/// Make an expectation on a given actual value. The value given is lazily evaluated.
@warn_unused_result(message="Follow 'expect(…)' with '.to(…)', '.toNot(…)', 'toEventually(…)', '==', etc.")
public func expect<T>(@autoclosure(escaping) expression: () throws -> T?, file: FileString = __FILE__, line: UInt = __LINE__) -> Expectation<T> {
public func expect<T>(@autoclosure(escaping) expression: () throws -> T?, file: FileString = #file, line: UInt = #line) -> Expectation<T> {
return Expectation(
expression: Expression(
expression: expression,
Expand All @@ -12,7 +12,7 @@ public func expect<T>(@autoclosure(escaping) expression: () throws -> T?, file:

/// Make an expectation on a given actual value. The closure is lazily invoked.
@warn_unused_result(message="Follow 'expect(…)' with '.to(…)', '.toNot(…)', 'toEventually(…)', '==', etc.")
public func expect<T>(file: FileString = __FILE__, line: UInt = __LINE__, expression: () throws -> T?) -> Expectation<T> {
public func expect<T>(file: FileString = #file, line: UInt = #line, expression: () throws -> T?) -> Expectation<T> {
return Expectation(
expression: Expression(
expression: expression,
Expand All @@ -27,12 +27,12 @@ public func fail(message: String, location: SourceLocation) {
}

/// Always fails the test with a message.
public func fail(message: String, file: FileString = __FILE__, line: UInt = __LINE__) {
public func fail(message: String, file: FileString = #file, line: UInt = #line) {
fail(message, location: SourceLocation(file: file, line: line))
}

/// Always fails the test.
public func fail(file: FileString = __FILE__, line: UInt = __LINE__) {
public func fail(file: FileString = #file, line: UInt = #line) {
fail("fail() always fails", file: file, line: line)
}

Expand All @@ -41,8 +41,8 @@ internal func nimblePrecondition(
@autoclosure expr: () -> Bool,
@autoclosure _ name: () -> String,
@autoclosure _ message: () -> String,
file: StaticString = __FILE__,
line: UInt = __LINE__) -> Bool {
file: StaticString = #file,
line: UInt = #line) -> Bool {
let result = expr()
if !result {
#if _runtime(_ObjC)
Expand All @@ -59,7 +59,7 @@ internal func nimblePrecondition(
}

@noreturn
internal func internalError(msg: String, file: FileString = __FILE__, line: UInt = __LINE__) {
internal func internalError(msg: String, file: FileString = #file, line: UInt = #line) {
fatalError(
"Nimble Bug Found: \(msg) at \(file):\(line).\n" +
"Please file a bug to Nimble: https://github.com/Quick/Nimble/issues with the " +
Expand Down
2 changes: 1 addition & 1 deletion Sources/Nimble/Matchers/MatcherProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

/// Implement this protocol to implement a custom matcher for Swift
public protocol Matcher {
typealias ValueType
associatedtype ValueType
func matches(actualExpression: Expression<ValueType>, failureMessage: FailureMessage) throws -> Bool
func doesNotMatch(actualExpression: Expression<ValueType>, failureMessage: FailureMessage) throws -> Bool
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Nimble/Utils/Async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ internal class AwaitPromiseBuilder<T> {
/// - The async expectation raised an unexpected error (swift)
///
/// The returned AwaitResult will NEVER be .Incomplete.
func wait(fnName: String = __FUNCTION__, file: FileString = __FILE__, line: UInt = __LINE__) -> AwaitResult<T> {
func wait(fnName: String = #function, file: FileString = #file, line: UInt = #line) -> AwaitResult<T> {
waitLock.acquireWaitingLock(
fnName,
file: file,
Expand Down Expand Up @@ -338,7 +338,7 @@ internal func pollBlock(
timeoutInterval: NSTimeInterval,
file: FileString,
line: UInt,
fnName: String = __FUNCTION__,
fnName: String = #function,
expression: () throws -> Bool) -> AwaitResult<Bool> {
let awaiter = NimbleEnvironment.activeInstance.awaiter
let result = awaiter.poll(pollInterval) { () throws -> Bool? in
Expand Down
6 changes: 3 additions & 3 deletions Tests/Nimble/AsynchronousTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ class AsyncTest: XCTestCase, XCTestCaseProvider {
func testCombiningAsyncWaitUntilAndToEventuallyIsNotAllowed() {
// Currently we are unable to catch Objective-C exceptions when built by the Swift Package Manager
#if !SWIFT_PACKAGE
let referenceLine = __LINE__ + 9
let referenceLine = #line + 9
var msg = "Unexpected exception raised: Nested async expectations are not allowed "
msg += "to avoid creating flaky tests."
msg += "\n\n"
msg += "The call to\n\t"
msg += "expect(...).toEventually(...) at \(__FILE__):\(referenceLine + 7)\n"
msg += "expect(...).toEventually(...) at \(#file):\(referenceLine + 7)\n"
msg += "triggered this exception because\n\t"
msg += "waitUntil(...) at \(__FILE__):\(referenceLine + 1)\n"
msg += "waitUntil(...) at \(#file):\(referenceLine + 1)\n"
msg += "is currently managing the main run loop."
failsWithErrorMessage(msg) { // reference line
waitUntil(timeout: 2.0) { done in
Expand Down
6 changes: 3 additions & 3 deletions Tests/Nimble/Helpers/utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
@testable import Nimble
import XCTest

func failsWithErrorMessage(messages: [String], file: FileString = __FILE__, line: UInt = __LINE__, preferOriginalSourceLocation: Bool = false, closure: () throws -> Void) {
func failsWithErrorMessage(messages: [String], file: FileString = #file, line: UInt = #line, preferOriginalSourceLocation: Bool = false, closure: () throws -> Void) {
var filePath = file
var lineNumber = line

Expand Down Expand Up @@ -44,7 +44,7 @@ func failsWithErrorMessage(messages: [String], file: FileString = __FILE__, line
}
}

func failsWithErrorMessage(message: String, file: FileString = __FILE__, line: UInt = __LINE__, preferOriginalSourceLocation: Bool = false, closure: () -> Void) {
func failsWithErrorMessage(message: String, file: FileString = #file, line: UInt = #line, preferOriginalSourceLocation: Bool = false, closure: () -> Void) {
return failsWithErrorMessage(
[message],
file: file,
Expand All @@ -54,7 +54,7 @@ func failsWithErrorMessage(message: String, file: FileString = __FILE__, line: U
)
}

func failsWithErrorMessageForNil(message: String, file: FileString = __FILE__, line: UInt = __LINE__, preferOriginalSourceLocation: Bool = false, closure: () -> Void) {
func failsWithErrorMessageForNil(message: String, file: FileString = #file, line: UInt = #line, preferOriginalSourceLocation: Bool = false, closure: () -> Void) {
failsWithErrorMessage("\(message) (use beNil() to match nils)", file: file, line: line, preferOriginalSourceLocation: preferOriginalSourceLocation, closure: closure)
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Nimble/Matchers/PostNotificationTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class PostNotificationTest: XCTestCase, XCTestCaseProvider {
return nil
}.toEventually(postNotifications(equal([testNotification]), fromNotificationCenter: notificationCenter))
#else
print("\(__FUNCTION__) is missing because toEventually is not implement on this platform")
print("\(#function) is missing because toEventually is not implement on this platform")
#endif
}
}
4 changes: 2 additions & 2 deletions Tests/Nimble/objc/ObjCContainTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ - (void)testPositiveMatches {
}

- (void)testNegativeMatches {
expectFailureMessage(@"expected to contain <Optional(3)>, got <(1, 2)>", ^{
expectFailureMessage(@"expected to contain <3>, got <(1, 2)>", ^{
expect((@[@1, @2])).to(contain(@3));
});
expectFailureMessage(@"expected to not contain <Optional(2)>, got <(1, 2)>", ^{
expectFailureMessage(@"expected to not contain <2>, got <(1, 2)>", ^{
expect((@[@1, @2])).toNot(contain(@2));
});

Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
machine:
xcode:
version: "7.0"
version: "7.3"

dependencies:
pre:
Expand Down