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