Show
Ignore:
Timestamp:
12/06/07 23:56:56 (13 months ago)
Author:
cho45
Message:

lang/javascript/jsdeferred/trunk/test-rhino.js:

最後にテストがうまくいったかどうか表示
色をつけるように

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/jsdeferred/trunk/test-rhino.js

    r2677 r2678  
    2323 
    2424        var out = []; 
    25         out.push("[", [expects - testfuns.length, expects].join("/"), "]"); 
     25        out.push(color(46, "[", [expects - testfuns.length, expects].join("/"), "]")); 
    2626        if (okng == "ng") { 
    2727                expect = (typeof expect == "function") ? uneval(expect).match(/[^{]+/)+"..." : uneval(expect); 
     
    3131                quit(); 
    3232        } else { 
    33                 out.push(" ", "ok"); 
     33                out.push(" ", color(32, "ok")); 
    3434                print(out.join("")); 
    3535        } 
     
    5656} 
    5757 
     58function color (code) { 
     59        var str = ""; 
     60        for (var i = 1; i < arguments.length; i++) str += arguments[i]; 
     61        return [ 
     62                String.fromCharCode(27), "[", code, "m", 
     63                str, 
     64                String.fromCharCode(27), "[0m" 
     65        ].join(""); 
     66} 
    5867 
    5968// run tests 
    6069eval(data); 
     70 
     71addFinalizer(function () { 
     72        if (expects - testfuns.length == expects) { 
     73                print(color(32, "All tests passed")); 
     74        } else { 
     75                print(color(31, "Some tests failed...")); 
     76        } 
     77}); 
    6178 
    6279//Deferred.define(); 
     
    122139        runQueue._id = 0; 
    123140 
     141        Global.addFinalizer = function (fun) { 
     142                Global.addFinalizer.finalizers.push(fun); 
     143        }; 
     144        Global.addFinalizer.finalizers = []; 
     145 
    124146        Global.setTimeout = function (func, delay) { 
    125147//              print("setTimeout:"+uneval(func)); 
     
    144166                        runQueue.process(); 
    145167                } 
     168                Global.addFinalizer.finalizers.forEach(function (i) { i() }); 
    146169        }); 
    147170})();