var good = 0, bad = 0; var ol = document.createElement("ol");
ol.style.display = "none"; var li = "", state = "pass"; for ( var i = 0; i < _config.Test.length; i++ ) { var li = document.createElement("li");
li.className = _config.Test[i][0] ? "pass" : "fail";
li.innerHTML = _config.Test[i][1];
ol.appendChild( li );
_config.stats.all++; if ( !_config.Test[i][0] ) {
state = "fail";
bad++;
_config.stats.bad++;
} else good++;
if ( parent.SimpleTest ){
parent.SimpleTest.ok( _config.Test[i][0], `${name}: ${_config.Test[i][1]}` );}
}
var li = document.createElement("li");
li.className = state;
var b = document.createElement("strong");
b.innerHTML = name + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + _config.Test.length + ")</b>";
b.onclick = function(){ var n = this.nextSibling; if ( jQuery.css( n, "display" ) == "none" )
n.style.display = "block"; else
n.style.display = "none";
};
$(b).dblclick(function(event) { var target = jQuery(event.target).filter("strong").clone(); if ( target.length ) {
target.children().remove();
location.href = location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent($.trim(target.text()));
}
});
li.appendChild( b );
li.appendChild( ol );
document.getElementById("tests").appendChild( li );
});
}
// call on start of module test to prepend name to all tests function module(moduleName) {
_config.currentModule = moduleName;
}
/** *Specifythenumberofexpectedassertionstoguranteethatfailedtest(noassertionsarerunatall)don'tslipthrough.
*/ function expect(asserts) {
_config.expected = asserts;
}
/** *Assertsthattwoarraysarethesame
*/ function isSet(a, b, msg) { var ret = true; if ( a && b && a.length != undefined && a.length == b.length ) { for ( var i = 0; i < a.length; i++ ) if ( a[i] != b[i] )
ret = false;
} else
ret = false; if ( !ret )
_config.Test.push( [ ret, msg + " expected: " + serialArray(b) + " result: " + serialArray(a) ] ); else
_config.Test.push( [ ret, msg ] );
}
/** *Assertsthattwoobjectsareequivalent
*/ function isObj(a, b, msg) { var ret = true;
if ( a && b ) { for ( var i in a ) if ( a[i] != b[i] )
ret = false;
for ( i in b ) if ( a[i] != b[i] )
ret = false;
} else
ret = false;
_config.Test.push( [ ret, msg ] );
}
function serialArray( a ) { var r = [];
if ( a && a.length ) for ( var i = 0; i < a.length; i++ ) { var str = a[i].nodeName; if ( str ) {
str = str.toLowerCase(); if ( a[i].id )
str += "#" + a[i].id;
} else
str = a[i];
r.push( str );
}
return "[ " + r.join(", ") + " ]";
}
/** *ReturnsanarrayofelementswiththegivenIDs,eg. *@exampleq("main","foo","bar") *@result[<divid="main">,<spanid="foo">,<inputid="bar">]
*/ function q() { var r = []; for ( var i = 0; i < arguments.length; i++ )
r.push( document.getElementById( arguments[i] ) );
return r;
}
/** *AssertsthataselectmatchesthegivenIDs *@examplet("Checkforsomething","//[a]", ["foo", "baar"]); *@resultreturnstrueif"//[a]" return two elements with the IDs 'foo' and 'baar'
*/ function t(a,b,c) { var f = jQuery(b); var s = ""; for ( var i = 0; i < f.length; i++ )
s += (s && ",") + '"' + f[i].id + '"';
isSet(f, q.apply(q,c), a + " (" + b + ")");
}
/** *AddrandomnumbertourltostopIEfromcaching * *@exampleurl("data/test.html") *@result"data/test.html?10538358428943" * *@exampleurl("data/test.php?foo=bar") *@result"data/test.php?foo=bar&10538358345554"
*/ function url(value) {
return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.