增加解释器WASM错误夹具
结论:解释器核心WASM验证新增零进给、弧半径、零半径弧和G53增量模式错误夹具,按现有canonical error期望校验错误文本与禁止事件。
This commit is contained in:
@@ -27,6 +27,28 @@ function runProgram(mod, programText) {
|
||||
}
|
||||
}
|
||||
|
||||
function verifyExpectedOutput(fixtureName, output, expectedText) {
|
||||
const expectedLines = expectedText.split("\n").filter(Boolean);
|
||||
|
||||
for (const expectedLine of expectedLines) {
|
||||
if (expectedLine.startsWith("absent=")) {
|
||||
const forbidden = expectedLine.slice("absent=".length);
|
||||
assert.equal(
|
||||
output.includes(forbidden),
|
||||
false,
|
||||
`${fixtureName}: unexpected ${forbidden}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
assert.equal(
|
||||
output.includes(expectedLine),
|
||||
true,
|
||||
`${fixtureName}: ${expectedLine}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const rootDir = resolve(__dirname, "../../..");
|
||||
@@ -66,16 +88,26 @@ for (const fixtureName of fixtureNames) {
|
||||
"utf8",
|
||||
).trimEnd();
|
||||
|
||||
const output = runProgram(interp, programText);
|
||||
const actualLineSet = new Set(output.split("\n").filter(Boolean));
|
||||
const expectedLines = expectedEvents.split("\n").filter(Boolean);
|
||||
verifyExpectedOutput(fixtureName, runProgram(interp, programText), expectedEvents);
|
||||
}
|
||||
|
||||
for (const expectedLine of expectedLines) {
|
||||
assert.equal(
|
||||
actualLineSet.has(expectedLine),
|
||||
true,
|
||||
`${fixtureName}: ${expectedLine}`,
|
||||
);
|
||||
}
|
||||
const errorFixtureNames = [
|
||||
"g1_zero_feed",
|
||||
"arc_radius_mismatch",
|
||||
"arc_zero_radius",
|
||||
"g53_incremental",
|
||||
];
|
||||
|
||||
for (const fixtureName of errorFixtureNames) {
|
||||
const programText = readFileSync(
|
||||
resolve(rootDir, `tests/fixtures/gcode_errors/${fixtureName}.ngc`),
|
||||
"utf8",
|
||||
);
|
||||
const expectedOutput = readFileSync(
|
||||
resolve(rootDir, `tests/fixtures/canon_errors/${fixtureName}.expected`),
|
||||
"utf8",
|
||||
).trimEnd();
|
||||
|
||||
verifyExpectedOutput(fixtureName, runProgram(interp, programText), expectedOutput);
|
||||
}
|
||||
console.log("interp_wasm_node_smoke=ok");
|
||||
|
||||
Reference in New Issue
Block a user