             let expectation = self.expectation(description: "\(i)")
             
             let promise = Promise<Int> { resolve in
-                queue1.asyncAfter(deadline: DispatchTime.now() + Double(Int64(0.01 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)) {
+                queue1.asyncAfter(deadline: .now() + 0.01) {
                     resolve(Promise(2))
                 }
             }
             
-            queue2.asyncAfter(deadline: DispatchTime.now() + Double(Int64(0.01 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)) {
+            queue2.asyncAfter(deadline: .now() + 0.01) {
                 let _: Promise<Int> = promise.flatMap {
                     expectation.fulfill()
                     return Promise($0 * $0)

    return asyncGetOrFail(value, arc4random() % 2 == 0)
}

func foo(_ a: Int, _ b: Int) -> (Int, Int) {
    return (a, b)
}

func curry<A, B, Z>(_ f: @escaping (A, B) -> Z) -> (A) -> (B) -> Z {
    return { a in { b in f(a, b) } }
}

struct FooError: Error {
    var value: Int
}


class PromiseKTests: XCTestCase {
    func testMap() {
        let squared = asyncGet(3).map {
            $0 * $0
        }
        
        XCTAssertEqual(squared.sync(), 9)
    }
    
    func testFlatMap() {
        do {
            let a = asyncGet(2)
            let b = asyncGet(3)
            let sum = a.flatMap { a in
                b.map { b in
                    a + b
                }
            }
            
            XCTAssertEqual(sum.sync(), 5)
        }
        
        do {
            let sum = asyncGet(2).flatMap { a in
                asyncGet(3).map { b in
                    a + b
                }
            }
            
            XCTAssertEqual(sum.sync(), 5)
        }
    }
    
