cleanup(testing): clean up public api spec

Change the old public api spec to check only the exported top-level symbols. This will make sure that Dart and JS do not diverge. The new public api spec verifies the TS api.

Closes #7447
This commit is contained in:
vsavkin
2016-03-11 09:00:18 -08:00
committed by Victor Savkin
parent c25b9fcf97
commit 201475e8d8
5 changed files with 120 additions and 1641 deletions

View File

@ -27,47 +27,12 @@ const IGNORE =
wrapperStack: true, '@@observable': true
}
function collectClassSymbols(symbols: string[], prefix: String, type: Function):
void {
// static
for (var name in type) {
if (IGNORE[name] || name.charAt(0) == '_') continue;
var suf = type[name] instanceof Function ? '()' : '';
var symbol = `${prefix}#${name}${suf}`;
symbols.push(symbol);
}
// instance
for (var name in type.prototype) {
if (IGNORE[name] || name.charAt(0) == '_') continue;
if (name == 'constructor') continue;
var suf = '';
try {
if (type.prototype[name] instanceof Function) suf = '()';
} catch (e) {
}
var symbol = `${prefix}.${name}${suf}`;
symbols.push(symbol);
}
}
function collectTopLevelSymbols(prefix: string, lib: any):
string[] {
var symbols: string[] = [];
for (var name in lib) {
var symbol = `${name}`;
var ref = lib[name];
if (ref instanceof Function) {
if (symbol.charAt(0) == symbol.charAt(0).toLowerCase()) {
// assume it is top level function
symbols.push(symbol + '()');
} else {
symbols.push(symbol);
collectClassSymbols(symbols, symbol, ref);
}
} else {
symbols.push(symbol);
}
symbols.push(symbol);
}
return symbols;
}