2006-08-14 03:47:47 +02:00
|
|
|
load( "build/js/writeFile.js", "build/js/parse.js" );
|
|
|
|
|
2006-09-16 14:19:56 +02:00
|
|
|
function addParams(name, params) {
|
|
|
|
if(params.length > 0) {
|
|
|
|
name += "(";
|
|
|
|
for ( var i = 0; i < params.length; i++) {
|
|
|
|
name += params[i].type + ", ";
|
|
|
|
}
|
|
|
|
return name.substring(0, name.length - 2) + ")";
|
|
|
|
} else {
|
|
|
|
return name + "()";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function addTestWrapper(name, test) {
|
|
|
|
return 'test("' + name + '", function() {\n' + test + '\n});';
|
|
|
|
}
|
2006-08-14 03:47:47 +02:00
|
|
|
|
2006-09-16 14:19:56 +02:00
|
|
|
var dir = arguments[1];
|
2006-10-08 11:57:17 +02:00
|
|
|
var jq = parse( read(arguments[0]) );
|
2006-08-14 03:47:47 +02:00
|
|
|
|
2006-09-16 14:19:56 +02:00
|
|
|
var testFile = [];
|
2006-08-25 20:38:24 +02:00
|
|
|
|
2006-09-17 13:41:44 +02:00
|
|
|
String.prototype.decode = function() {
|
|
|
|
return this.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
|
|
};
|
|
|
|
|
2006-08-14 03:47:47 +02:00
|
|
|
for ( var i = 0; i < jq.length; i++ ) {
|
|
|
|
if ( jq[i].tests.length > 0 ) {
|
2006-09-16 14:19:56 +02:00
|
|
|
var method = jq[i];
|
|
|
|
var name = addParams(method.name, method.params);
|
2006-09-30 16:34:49 +02:00
|
|
|
for(var j = 0; j < method.tests.length; j++) {
|
|
|
|
if(j > 0) {
|
|
|
|
name += "x";
|
|
|
|
}
|
|
|
|
testFile[testFile.length] = addTestWrapper(name, method.tests[j].decode()) + "\n";
|
|
|
|
}
|
2006-08-14 03:47:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-17 13:41:44 +02:00
|
|
|
var indexFile = readFile( "build/test/index.html" );
|
|
|
|
writeFile( dir + "/index.html", indexFile.replace( /{TESTS}/g, testFile.join("\n") ) );
|