         
         XCTAssertEqual(42, answer, "andThens should be executed in order")
     }
+    
+    func testMapSuccess() {
+        let e = self.expectationWithDescription("")
+        
+        future { _ in
+            fibonacci(10)
+        }.map { value, _ -> String? in
+            if value > 5 {
+                return "large"
+            }
+            return "small"
+        }.map { sizeString, _ -> Bool? in
+            return sizeString == "large"
+        }.onSuccess { numberIsLarge in
+            XCTAssert(numberIsLarge)
+            e.fulfill()
+        }
+        
+        self.waitForExpectationsWithTimeout(2, handler: nil)
+    }
+    
+    func testMapFailure() {
+        
+        let e = self.expectationWithDescription("")
+        
+        future { (inout error:NSError?) -> Int? in
+            error = NSError(domain: "Tests", code: 123, userInfo: nil)
+            return nil
+        }.map { number, _ in
+            XCTAssert(false, "map should not be evaluated because of failure above")
+        }.map { number, _ in
+            XCTAssert(false, "this map should also not be evaluated because of failure above")
+        }.onFailure { error in
+            XCTAssert(error.domain == "Tests")
+            e.fulfill()
+        }
+        
+        self.waitForExpectationsWithTimeout(2, handler: nil)
+    }
 
     func testSkippedRecover() {
         let e = self.expectationWithDescription("")

        
        self.waitForExpectationsWithTimeout(10, handler: nil)
    }
    
    func failingFuture<U>() -> Future<U> {
        return future { error in

            usleep(arc4random_uniform(100))
            return val
        }
    }
}

