File tree 2 files changed +34
-0
lines changed
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -377,4 +377,29 @@ - (void)waitUntilFinished {
377
377
[self .condition unlock ];
378
378
}
379
379
380
+ #pragma mark - NSObject
381
+
382
+ - (NSString *)description {
383
+ // Acquire the data from the locked properties
384
+ BOOL isCompleted;
385
+ BOOL isCancelled;
386
+ BOOL isFaulted;
387
+
388
+ @synchronized (self.lock ) {
389
+ isCompleted = self.completed ;
390
+ isCancelled = self.cancelled ;
391
+ isFaulted = self.faulted ;
392
+ }
393
+
394
+ // Description string includes status information and, if available, the
395
+ // result sisnce in some ways this is what a promise actually "is".
396
+ return [NSString stringWithFormat: @" <%@ : %p ; completed = %@ ; cancelled = %@ ; faulted = %@ ;%@ >" ,
397
+ NSStringFromClass ([self class ]),
398
+ self ,
399
+ isCompleted ? @" YES" : @" NO" ,
400
+ isCancelled ? @" YES" : @" NO" ,
401
+ isFaulted ? @" YES" : @" NO" ,
402
+ isCompleted ? [NSString stringWithFormat: @" result:%@ " , _result] : @" " ];
403
+ }
404
+
380
405
@end
Original file line number Diff line number Diff line change @@ -534,4 +534,13 @@ - (void)testExecuteOnOperationQueue {
534
534
[task waitUntilFinished ];
535
535
}
536
536
537
+ - (void )testDescription {
538
+ BFTask *task = [BFTask taskWithResult: nil ];
539
+ NSString *expected = [NSString stringWithFormat: @" <BFTask: %p ; completed = YES; cancelled = NO; faulted = NO; result:(null)>" , task];
540
+
541
+ NSString *description = task.description ;
542
+
543
+ XCTAssertTrue ([expected isEqualToString: description]);
544
+ }
545
+
537
546
@end
You can’t perform that action at this time.
0 commit comments