Skip to content
This repository has been archived by the owner on Dec 4, 2017. It is now read-only.

Commit

Permalink
Cleaned up for Xcode 8 GM
Browse files Browse the repository at this point in the history
  • Loading branch information
justin committed Sep 7, 2016
1 parent 14db048 commit 3a03c29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 0 additions & 2 deletions AspenTests/AspenHelperTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
@import XCTest;
@import Aspen;

#import "AspenTests-Swift.h"

@interface TestObjectPass : NSObject
@end
@implementation TestObjectPass
Expand Down
10 changes: 5 additions & 5 deletions AspenTests/AspenTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import XCTest


// Thx Matt Neuberg
func delay(_ delay: Double, block: () -> Void)
func delay(_ delay: Double, block: @escaping () -> Void)
{
DispatchQueue.global(qos: .background).asyncAfter(deadline: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: block)
}
Expand Down Expand Up @@ -53,7 +53,7 @@ class AspenTestCase: XCTestCase {

let _ = self.expectation(forNotification: AspenDidLogNotification, object: logNotifier!, handler: nil)
test()
self.waitForExpectations(withTimeout: timeout) { error in
self.waitForExpectations(timeout: timeout) { error in
XCTAssertNil(error, "Expected log to fire. Set a breakpoint here to see which test failed")
}
}
Expand All @@ -71,7 +71,7 @@ class AspenTestCase: XCTestCase {
self.addNoLogObserver()

// Because we expect a log to _not_ happen, we set up a basic timeout which signals success
let expectation = self.expectation(withDescription: "Expected disqualified log to time out")
let expectation = self.expectation(description: "Expected disqualified log to time out")
delay(0.5) {
// Remove the observer ASAP, to mitigate the race-y issues addressed by addNoLogObserver()
self.removeNoLogObserver()
Expand All @@ -83,7 +83,7 @@ class AspenTestCase: XCTestCase {
test()

// This should never time out; it should either pass, or fail via overt XCTFail in the notification observer
self.waitForExpectations(withTimeout: 1.0) { error in
self.waitForExpectations(timeout: 1.0) { error in
XCTAssertNil(error, "Unreachable: Should have timed out waiting for log to not happen but got \(error)")
}
}
Expand All @@ -103,7 +103,7 @@ class AspenTestCase: XCTestCase {
observer = NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: AspenDidLogNotification), object: logNotifier!, queue: queue) { [weak self] notification in
// Avoid false positives by confirming that the assumed current observer is the observer that was actually tripped here
// That way we don't fail one test for receiving another test's late notification
if let obs1 = observer where obs1.isEqual(self?.noLogObserver)
if let obs1 = observer , obs1.isEqual(self?.noLogObserver)
{
XCTFail("Did not expect a log message during this test; got \((notification as NSNotification).userInfo?[AspenNotificationKeyMessage])")
}
Expand Down

0 comments on commit 3a03c29

Please sign in to comment.