Do a line-by-line comparison for AST checking
This changes the test harness to do a line-by-line comparison, rather than full text comparison, for AST checking. This is a bit nicer to diagnose, because failures will specifically point out the line that deviates, rather than dumping the (possibly huge) string containing the full expected/actual ASTs.
This commit is contained in:
parent
f2f6826f5b
commit
57e8a6aa67
1 changed files with 11 additions and 3 deletions
|
@ -62,9 +62,17 @@ describe("outputs", () => {
|
||||||
|
|
||||||
if (output.tree) {
|
if (output.tree) {
|
||||||
if (expectedOutputTree) {
|
if (expectedOutputTree) {
|
||||||
let mupackTree: pack.Package = compiler.transform(output.tree);
|
let muMeta: pack.Metadata = await compiler.discover(output.root);
|
||||||
let mupackTreeText: string = JSON.stringify(mupackTree, null, 4) + os.EOL;
|
let mupackTree: pack.Package = compiler.transform(muMeta, output.tree);
|
||||||
assert.strictEqual(mupackTreeText, expectedOutputTree, "Expected program trees to match");
|
let mupackTreeText: string = JSON.stringify(mupackTree, null, 4) + "\n";
|
||||||
|
|
||||||
|
// Do a line-by-line comparison to make debugging failures nicer.
|
||||||
|
let actualLines: string[] = mupackTreeText.split("\n");
|
||||||
|
let expectLines: string[] = expectedOutputTree.split("\n");
|
||||||
|
assert.strictEqual(actualLines.length, expectLines.length, "Expected tree line count to match");
|
||||||
|
for (let i = 0; i < actualLines.length && i < expectLines.length; i++) {
|
||||||
|
assert.strictEqual(actualLines[i], expectLines[i], `Expected tree line #${i} to match`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(false, "Expected an empty program tree, but one was returned");
|
assert(false, "Expected an empty program tree, but one was returned");
|
||||||
|
|
Loading…
Reference in a new issue