mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 10:29:18 -05:00
Improve test 262 baselines.
This commit is contained in:
@@ -27,9 +27,12 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function getFlagName(flags: any, f: number): any {
|
||||
if (f === 0) return 0;
|
||||
if (f === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var result = "";
|
||||
ts.forEach(Object.getOwnPropertyNames(flags),(v: any) => {
|
||||
ts.forEach(Object.getOwnPropertyNames(flags), (v: any) => {
|
||||
if (isFinite(v)) {
|
||||
v = +v;
|
||||
if (f === +v) {
|
||||
@@ -51,45 +54,56 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
function getParserContextFlagName(f: number) { return getFlagName((<any>ts).ParserContextFlags, f); }
|
||||
|
||||
function serializeNode(n: ts.Node): any {
|
||||
var o = { kind: getKindName(n.kind) };
|
||||
ts.forEach(Object.getOwnPropertyNames(n), i => {
|
||||
switch (i) {
|
||||
var o: any = { kind: getKindName(n.kind) };
|
||||
|
||||
ts.forEach(Object.getOwnPropertyNames(n), propertyName => {
|
||||
switch (propertyName) {
|
||||
case "parent":
|
||||
case "symbol":
|
||||
case "locals":
|
||||
case "localSymbol":
|
||||
case "kind":
|
||||
case "semanticDiagnostics":
|
||||
case "parseDiagnostics":
|
||||
case "grammarDiagnostics":
|
||||
return undefined;
|
||||
case "id":
|
||||
case "nodeCount":
|
||||
case "symbolCount":
|
||||
case "identifierCount":
|
||||
// Blacklist of items we never put in the baseline file.
|
||||
break;
|
||||
|
||||
case "flags":
|
||||
(<any>o)[i] = getNodeFlagName(n.flags);
|
||||
return undefined;
|
||||
// Print out flags with their enum names.
|
||||
o[propertyName] = getNodeFlagName(n.flags);
|
||||
break;
|
||||
|
||||
case "parserContextFlags":
|
||||
(<any>o)[i] = getParserContextFlagName(n.parserContextFlags);
|
||||
return undefined;
|
||||
o[propertyName] = getParserContextFlagName(n.parserContextFlags);
|
||||
break;
|
||||
|
||||
case "nextContainer":
|
||||
if (n.nextContainer) {
|
||||
(<any>o)[i] = { kind: n.nextContainer.kind, pos: n.nextContainer.pos, end: n.nextContainer.end };
|
||||
return undefined;
|
||||
o[propertyName] = { kind: n.nextContainer.kind, pos: n.nextContainer.pos, end: n.nextContainer.end };
|
||||
}
|
||||
break;
|
||||
|
||||
case "text":
|
||||
if (n.kind === ts.SyntaxKind.SourceFile) return undefined;
|
||||
// Include 'text' field for identifiers/literals, but not for source files.
|
||||
if (n.kind !== ts.SyntaxKind.SourceFile) {
|
||||
o[propertyName] = (<any>n)[propertyName];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
(<any>o)[i] = ((<any>n)[i]);
|
||||
o[propertyName] = (<any>n)[propertyName];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
});
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
return JSON.stringify(file,(k, v) => {
|
||||
return JSON.stringify(file, (k, v) => {
|
||||
return (v && typeof v.pos === "number") ? serializeNode(v) : v;
|
||||
}, " ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user