     let canceled = deferred.cancel()
     XCTAssert(canceled)
 
-    if let error = deferred.error
-    {
-      let e = error as NSError
+    switch deferred.result
+    {
+    case let .Error(e as NSError):
       XCTAssert(e.domain == NSURLErrorDomain)
       XCTAssert(e.code == NSURLErrorCancelled)
-    }
-    else
-    {
-      XCTFail()
+    default:
+      XCTFail("failed to cancel?")
     }
 
     session.invalidateAndCancel()


    let deferred = session.deferredDownloadTask(request)

    if let (_, handle, response) = deferred.value
    {
      let data = handle.readDataToEndOfFile()
      handle.closeFile()
      XCTAssert(data.length > 0)
      XCTAssert(response.statusCode == 404)
    }
    else
    {
      XCTFail()
    }

    session.invalidateAndCancel()

      return session.deferredDownloadTask(url)
    }()

    usleep(1000)

    switch deferred.result
    {
    case .Error(let e as NSError):
      // Nope: XCTAssertNil(deferred.task)
      XCTAssert(e.domain == NSURLErrorDomain)
      print(String(e))

    default:
      XCTFail("failed to cancel?")
    }

    let canceled = deferred.cancel()
    XCTAssert(canceled == false)
