Skip to content

Commit

Permalink
Add deprecation ignore for warnings in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
nlutsenko committed May 20, 2016
1 parent b6dcaa4 commit 370a26a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
3 changes: 3 additions & 0 deletions BoltsTests/ExecutorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ - (void)testExecuteOnDispatchQueue {

BFTask *task = [BFTask taskWithResult:nil];
task = [task continueWithExecutor:queueExecutor withBlock:^id(BFTask *task) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertEqual(queue, dispatch_get_current_queue());
#pragma clang diagnostic pop
return nil;
}];
[task waitUntilFinished];
Expand Down
35 changes: 30 additions & 5 deletions BoltsTests/TaskTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ - (void)testBasicContinueWithException {
[NSException raise:NSInternalInconsistencyException format:message];
return nil;
}] continueWithBlock:^id(BFTask *task) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertNotNil(task.exception, @"Task should have failed.");
XCTAssertEqualObjects(message, task.exception.description);
#pragma clang diagnostic pop
return nil;
}] waitUntilFinished];
}
Expand Down Expand Up @@ -171,6 +174,8 @@ - (void)testFinishLaterWithError {
- (void)testFinishLaterWithException {
NSString *message = @"This is expected.";
BFTaskCompletionSource *tcs = [BFTaskCompletionSource taskCompletionSource];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
BFTask *task = [tcs.task continueWithBlock:^id(BFTask *task) {
XCTAssertNotNil(task.exception, @"Task should have failed.");
XCTAssertEqualObjects(message, task.exception.description);
Expand All @@ -179,6 +184,7 @@ - (void)testFinishLaterWithException {
[tcs setException:[NSException exceptionWithName:NSInternalInconsistencyException
reason:message
userInfo:nil]];
#pragma clang diagnostic pop
[task waitUntilFinished];
}

Expand Down Expand Up @@ -336,7 +342,10 @@ - (void)testTaskForCompletionOfAllTasksSuccess {

[[[BFTask taskForCompletionOfAllTasks:tasks] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertNil(task.exception);
#pragma clang diagnostic pop
XCTAssertFalse(task.isCancelled);

for (int i = 0; i < kTaskCount; ++i) {
Expand All @@ -362,6 +371,8 @@ - (void)testTaskForCompletionOfAllTasksOneException {

[[[BFTask taskForCompletionOfAllTasks:tasks] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertNotNil(task.exception);
XCTAssertFalse(task.isCancelled);

Expand All @@ -374,6 +385,7 @@ - (void)testTaskForCompletionOfAllTasksOneException {
XCTAssertEqual(i, [((BFTask *)[tasks objectAtIndex:i]).result intValue]);
}
}
#pragma clang diagnostic pop
return nil;
}] waitUntilFinished];
}
Expand All @@ -394,6 +406,8 @@ - (void)testTaskForCompletionOfAllTasksTwoExceptions {

[[[BFTask taskForCompletionOfAllTasks:tasks] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertNotNil(task.exception);
XCTAssertFalse(task.isCancelled);

Expand All @@ -411,6 +425,7 @@ - (void)testTaskForCompletionOfAllTasksTwoExceptions {
XCTAssertEqual(i, [((BFTask *)[tasks objectAtIndex:i]).result intValue]);
}
}
#pragma clang diagnostic pop
return nil;
}] waitUntilFinished];
}
Expand All @@ -433,7 +448,6 @@ - (void)testTaskForCompletionOfAllTasksOneError {

[[[BFTask taskForCompletionOfAllTasks:tasks] continueWithBlock:^id(BFTask *task) {
XCTAssertNotNil(task.error);
XCTAssertNil(task.exception);
XCTAssertFalse(task.isCancelled);

XCTAssertEqualObjects(@"BoltsTests", task.error.domain);
Expand Down Expand Up @@ -468,7 +482,6 @@ - (void)testTaskForCompletionOfAllTasksTwoErrors {

[[[BFTask taskForCompletionOfAllTasks:tasks] continueWithBlock:^id(BFTask *task) {
XCTAssertNotNil(task.error);
XCTAssertNil(task.exception);
XCTAssertFalse(task.isCancelled);

XCTAssertEqualObjects(@"bolts", task.error.domain);
Expand Down Expand Up @@ -507,7 +520,6 @@ - (void)testTaskForCompletionOfAllTasksCancelled {

[[[BFTask taskForCompletionOfAllTasks:tasks] continueWithBlock:^id(BFTask *task) {
XCTAssertNil(task.error);
XCTAssertNil(task.exception);
XCTAssertTrue(task.isCancelled);

for (int i = 0; i < kTaskCount; ++i) {
Expand Down Expand Up @@ -566,6 +578,8 @@ - (void)testTaskForCompletionOfAllTasksErrorCancelledSuccess {
}

- (void)testTaskForCompletionOfAllTasksExceptionCancelledSuccess {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSException *exception = [NSException exceptionWithName:@"" reason:@"" userInfo:nil];
BFTask *exceptionTask = [BFTask taskWithException:exception];
BFTask *cancelledTask = [BFTask cancelledTask];
Expand All @@ -576,9 +590,12 @@ - (void)testTaskForCompletionOfAllTasksExceptionCancelledSuccess {
XCTAssertTrue(allTasks.faulted, @"Task should be faulted");
XCTAssertNil(allTasks.error, @"Task shoud not have error");
XCTAssertNotNil(allTasks.exception, @"Task should have exception");
#pragma clang diagnostic pop
}

- (void)testTaskForCompletionOfAllTasksExceptionErrorCancelledSuccess {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
BFTask *errorTask = [BFTask taskWithError:[NSError new]];
BFTask *exceptionTask = [BFTask taskWithException:[NSException new]];
BFTask *cancelledTask = [BFTask cancelledTask];
Expand All @@ -589,6 +606,7 @@ - (void)testTaskForCompletionOfAllTasksExceptionErrorCancelledSuccess {
XCTAssertTrue(allTasks.faulted, @"Task should be faulted");
XCTAssertNotNil(allTasks.error, @"Task should have error");
XCTAssertNil(allTasks.exception, @"Task should not have exception");
#pragma clang diagnostic pop
}

- (void)testTaskForCompletionOfAllTasksErrorCancelled {
Expand Down Expand Up @@ -682,13 +700,11 @@ - (void)testTasksForTaskForCompletionOfAnyTasksWithError {
}

- (void)testTasksForTaskForCompletionOfAnyTasksWithNilArray {

BFTask *task = [BFTask taskForCompletionOfAnyTask:nil];
[task waitUntilFinished];

XCTAssertNil(task.result);
XCTAssertNil(task.error);
XCTAssertNil(task.exception);
}

- (void)testTasksForTaskForCompletionOfAnyTasksAllErrors {
Expand Down Expand Up @@ -742,7 +758,10 @@ - (void)testTaskFromExecutor {
BFExecutor *queueExecutor = [BFExecutor executorWithDispatchQueue:queue];

BFTask *task = [BFTask taskFromExecutor:queueExecutor withBlock:^id() {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
XCTAssertEqual(queue, dispatch_get_current_queue());
#pragma clang diagnostic pop
return @"foo";
}];
[task waitUntilFinished];
Expand Down Expand Up @@ -817,25 +836,31 @@ - (void)testTrySetError {
- (void)testSetException {
BFTaskCompletionSource *taskCompletionSource = [BFTaskCompletionSource taskCompletionSource];

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException reason:@"test" userInfo:nil];
taskCompletionSource.exception = exception;
XCTAssertThrowsSpecificNamed([taskCompletionSource setException:exception], NSException, NSInternalInconsistencyException);

XCTAssertTrue(taskCompletionSource.task.completed);
XCTAssertTrue(taskCompletionSource.task.faulted);
XCTAssertEqualObjects(taskCompletionSource.task.exception, exception);
#pragma clang diagnostic pop
}

- (void)testTrySetException {
BFTaskCompletionSource *taskCompletionSource = [BFTaskCompletionSource taskCompletionSource];

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException reason:@"test" userInfo:nil];
[taskCompletionSource trySetException:exception];
[taskCompletionSource trySetException:exception];

XCTAssertTrue(taskCompletionSource.task.completed);
XCTAssertTrue(taskCompletionSource.task.faulted);
XCTAssertEqualObjects(taskCompletionSource.task.exception, exception);
#pragma clang diagnostic pop
}

- (void)testSetCancelled {
Expand Down

0 comments on commit 370a26a

Please sign in to comment.