Skip to content

Commit bba7850

Browse files
committed
moving test variant coverage into its own file
1 parent 2d26188 commit bba7850

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

tests/config/run-test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import * as testBom from "./test-bom.js";
99
import * as testEndOfLine from "./test-end-of-line.js";
1010
import * as testSecondFormat from "./test-second-format.js";
1111
import * as testBytecodeCompare from "./test-bytecode-compare.js";
12+
import * as testVariantCoverage from "./test-variant-coverage.js";
1213
import { shouldThrowOnFormat } from "./utilities.js";
1314
import getPrettier from "./get-prettier.js";
1415
import getCreateParser from "./get-create-parser.js";
15-
import getVariantCoverage from "./get-variant-coverage.js";
1616
import getPlugins from "./get-plugins.js";
1717

1818
async function runTest({
@@ -70,11 +70,7 @@ async function runTest({
7070

7171
if (formatOptions.parser === "slang") {
7272
const createParser = await getCreateParser();
73-
const variantCoverage = await getVariantCoverage();
74-
const { parser, parseOutput } = createParser(code, formatOptions);
75-
76-
// Check coverage
77-
variantCoverage(parseOutput.tree.asNonterminalNode());
73+
const { parser } = createParser(code, formatOptions);
7874

7975
if (!failedTests.isAntlrMismatch(filename, formatOptions)) {
8076
// Compare with ANTLR's format
@@ -91,6 +87,7 @@ async function runTest({
9187
}
9288
}
9389

90+
await testVariantCoverage.run(code, formatResult, filename, formatOptions);
9491
await testSecondFormat.run(code, formatResult, filename, formatOptions);
9592
await testAstCompare.run(code, formatResult, filename, formatOptions);
9693
await testEndOfLine.run(code, formatResult, filename, formatOptions, "\r\n");
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import getCreateParser from "./get-create-parser.js";
2+
import getVariantCoverage from "./get-variant-coverage.js";
3+
4+
async function testVariantCoverage(
5+
source,
6+
_formatResult,
7+
_filename,
8+
formatOptions,
9+
) {
10+
if (formatOptions.parser === "slang") {
11+
const createParser = await getCreateParser();
12+
const variantCoverage = await getVariantCoverage();
13+
const { parseOutput } = createParser(source, formatOptions);
14+
15+
// Check coverage
16+
variantCoverage(parseOutput.tree.asNonterminalNode());
17+
}
18+
}
19+
20+
export { testVariantCoverage as run };

0 commit comments

Comments
 (0)