Run AST_COMPARE test for verifyParsers too (#8966)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-08-19 21:26:33 +08:00
1 parent 36c35be210
commit d1a9d7420b
2 files changed
+50 -12

No files matched your search

+20 -10
View File
@@ -247,20 +247,30 @@ global.run_spec = (fixtures, parsers, options) => {
for (const parser of verifyParsers) {
const verifyOptions = { ...firstFormat.options, parser };
const verifyFormat = () => format(firstFormat.input, verifyOptions);
const runVerifyFormat = () => format(firstFormat.input, verifyOptions);
test(`verify (${parser})`, () => {
if (shouldThrowOnVerify(name, verifyOptions)) {
expect(verifyFormat).toThrow(
if (shouldThrowOnVerify(name, verifyOptions)) {
test(`verify (${parser})`, () => {
expect(runVerifyFormat).toThrow(
TEST_STANDALONE ? undefined : SyntaxError
);
return;
}
});
} else {
const verifyFormat = runVerifyFormat();
test(`verify (${parser})`, () => {
expect(verifyFormat.eolVisualizedOutput).toEqual(
firstFormat.eolVisualizedOutput
);
});
const { eolVisualizedOutput: verifyOutput } = verifyFormat();
const { eolVisualizedOutput: firstOutput } = firstFormat;
expect(verifyOutput).toEqual(firstOutput);
});
if (AST_COMPARE && verifyFormat.changed && code.trim()) {
test(`verify AST (${parser})`, () => {
const originalAst = parse(verifyFormat.input, verifyOptions);
const formattedAst = parse(verifyFormat.output, verifyOptions);
expect(originalAst).toEqual(formattedAst);
});
}
}
}
const isUnstableTest = isUnstable(filename, formatOptions);