     
     def1.done(105);
     def1.done(5);
-}; filterMapHotDeffered();
+}; filterMapHotTest();
 
-func mergePromise() {
+func mergeTest() {
     var def1 = Deffered<Int,Int>(isCold: false); //isCold: true for history playback
     
     //Merging

// Cold Futures store history and replays it to new listeners
import Foundation

func simpleHotDeffered() {
    var def1 = Deffered<Int,Int>(isCold: false);
    def1.done(3);
    def1.promise.success.forEach(){
        if($0==3) {println("fail simpleHotDeffered");}
        else if($0==5) {println("success simpleHotDeffered");}
    }
    def1.done(5);
}; simpleHotDeffered();

func simpleColdDeffered() {
    var def1 = Deffered<Int,Int>(isCold: true);
    def1.done(3);
    var step = 0;
    def1.promise.success.forEach(){
        if($0==3 && step==0) {step++}
        else if($0==5 && step==1) {println("success simpleColdDeffered");}
        else {println("failed simpleColdDeffered")}
    }
    def1.done(5);
}; simpleColdDeffered();

func filterMapHotDeffered() {
    var def1 = Deffered<Int,Int>(isCold: false); //isCold: true for history playback
    var p = def1.promise;
    

    def2.promise.success.merge(def1.promise.success).forEach() {
        switch $0 {
        case(let x, let y):
            if(x=="Hello" && y==5) { println("success mergeTest"); }
        default:
            println("fail mergeTest");
        }
    }
    def1.done(5);
    def2.done("Hello");
}; mergeTest();

func foldTest() {
    var def1 = Deffered<Int,Int>(isCold: false);
    var step = 0;
    var f = def1.promise.success.fold({$0 + $1}, total:1)
        .forEach() {
            if(step==0 && $0==1+2) { step++; }
            else if(step==1 && $0==1+2+3) { step++; }
            else if(step==2 && $0==1+2+3+4) { println("success foldTest") }
            else { println("fail foldTest") }
        }
    
    def1.done(2);
    def1.done(3);
    def1.done(4);
}; foldTest();

println("completed");