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

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

    switch deferred.result
    {
    case .error(let e as NSError):
      XCTAssert(e.domain == NSURLErrorDomain)
      XCTAssert(e.code == NSURLErrorCancelled)
    default:
      XCTFail("failed to cancel?")
    }



    usleep(1000)

    if let e = deferred.error as? URLError
    {
      _ = e
      // print(e.code.rawValue)
    }
    else
    {
      XCTFail("failed to cancel?")
    }

