7 $("#main").html(fixture);
9 fixture = $("#main").html();
13 function synchronize(callback) {
14 queue[queue.length] = callback;
21 while(queue.length && !blocking) {
23 queue = queue.slice(1);
28 function runTests(files) {
31 var startTime = new Date();
32 for( var i=0; i < files.length; i++) {
35 synchronize(function() {
36 var runTime = new Date() - startTime;
37 $('body').append('<br/>Tests completed in ' + runTime + ' milliseconds.');
41 function runTest( files, num ) {
42 synchronize(function() {
44 $.get(files[num],function(js){
45 js = js.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
50 if(typeof console != "undefined")
52 Test.push( [ false, "Died on test #" + (Test.length+1) + ": " + e ] );
55 var good = 0, bad = 0;
56 var ol = document.createElement("ol");
58 var li = "", state = "pass";
59 for ( var i = 0; i < Test.length; i++ ) {
60 var li = document.createElement("li");
61 li.className = Test[i][0] ? "pass" : "fail";
62 li.innerHTML = Test[i][1];
71 var li = document.createElement("li");
74 var b = document.createElement("b");
75 b.innerHTML = files[num] + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + Test.length + ")</b>";
76 b.onclick = function(){
77 var n = this.nextSibling;
78 if ( jQuery.css( n, "display" ) == "none" )
79 n.style.display = "block";
81 n.style.display = "none";
87 document.getElementById("tests").appendChild( li );
100 Test.push( [ !!a, msg ] );
103 function cmpOK( a, c, b, msg ) {
105 eval( "res = (a " + c + " b)" );
106 Test.push( [ res, msg ] );
109 function isSet(a, b, msg) {
112 if ( a && b && a.length == b.length ) {
119 if ( !ret && console )
120 console.log( msg, a, b );
122 Test.push( [ ret, msg ] );
128 for ( var i = 0; i < arguments.length; i++ )
129 r.push( document.getElementById( arguments[i] ) );
135 var f = jQuery.find(b);
138 for ( var i = 0; i < f.length; i++ )
139 s += (s && ",") + '"' + f[i].id + '"';
141 isSet(f, q.apply(q,c), a + " (" + b + ")");
145 var li = document.createElement("li");
147 if ( a.indexOf("#") == 0 )
148 li.className = "comment";
149 else if ( a.indexOf("TODO") >= 0 )
150 li.className = "todo";
151 else if ( a.indexOf("not ok") == 0 )
152 li.classname = "fail";
154 li.className = "pass";
155 document.getElementById("test").appendChild(li);
158 //plan({noPlan: true});