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-08-14 03:47:47 +02:00
|
|
|
var jq = parse( readFile( arguments[0] ) );
|
|
|
|
|
2006-09-16 14:19:56 +02:00
|
|
|
var testFile = [];
|
2006-08-25 20:38:24 +02:00
|
|
|
|
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);
|
|
|
|
testFile[testFile.length] = addTestWrapper(name, method.tests.join("\n"));
|
2006-08-14 03:47:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-16 14:19:56 +02:00
|
|
|
writeFile( dir + "/tests.js", testFile.join("\n") );
|