1 function runTests(files) {
5 function runTest( files, num ) {
6 $.get(files[num],function(js){
7 js = js.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
12 Test.push( [ false, "Died on test #" + Test.length + ": " + e ] );
15 var good = 0, bad = 0;
16 var ol = document.createElement("ol");
18 var li = "", state = "pass";
19 for ( var i = 0; i < Test.length; i++ ) {
20 var li = document.createElement("li");
21 li.className = Test[i][0] ? "pass" : "fail";
22 li.innerHTML = Test[i][1];
31 var li = document.createElement("li");
34 var b = document.createElement("b");
35 b.innerHTML = files[num] + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + Test.length + ")</b>";
36 b.onclick = function(){
37 var n = this.nextSibling;
38 if ( jQuery.css( n, "display" ) == "none" )
39 n.style.display = "block";
41 n.style.display = "none";
47 document.getElementById("tests").appendChild( li );
50 if ( ++num < files.length ) runTest( files, num );
57 Test.push( [ !!a, msg ] );
60 function cmpOK( a, c, b, msg ) {
62 eval( "res = (a " + c + " b)" );
63 Test.push( [ res, msg ] );
66 function isSet(a, b, msg) {
69 if ( a && b && a.length == b.length ) {
76 if ( !ret && console )
77 console.log( msg, a, b );
79 Test.push( [ ret, msg ] );
85 for ( var i = 0; i < arguments.length; i++ )
86 r.push( document.getElementById( arguments[i] ) );
92 var f = jQuery.find(b);
95 for ( var i = 0; i < f.length; i++ )
96 s += (s && ",") + '"' + f[i].id + '"';
98 isSet(f, q.apply(q,c), a + " (" + b + ")");
102 var li = document.createElement("li");
104 if ( a.indexOf("#") == 0 )
105 li.className = "comment";
106 else if ( a.indexOf("TODO") >= 0 )
107 li.className = "todo";
108 else if ( a.indexOf("not ok") == 0 )
109 li.classname = "fail";
111 li.className = "pass";
112 document.getElementById("test").appendChild(li);
115 //plan({noPlan: true});