增加解释器WASM错误夹具
结论:解释器核心WASM验证新增零进给、弧半径、零半径弧和G53增量模式错误夹具,按现有canonical error期望校验错误文本与禁止事件。
This commit is contained in:
@@ -195,10 +195,11 @@ INI parser smoke harness and an initial interpreter-core canonical event smoke
|
|||||||
for `minimal_linear`, `arc_semantics`, `length_units`, `modal_incremental`,
|
for `minimal_linear`, `arc_semantics`, `length_units`, `modal_incremental`,
|
||||||
`plane_selection`, `coordinate_offsets`, `g53_machine_coordinates`,
|
`plane_selection`, `coordinate_offsets`, `g53_machine_coordinates`,
|
||||||
`feed_control_modes`, `position_params`, `probe_semantics`, `spindle_orient`,
|
`feed_control_modes`, `position_params`, `probe_semantics`, `spindle_orient`,
|
||||||
`comment_logging`, and `numbered_params`. OPFS validation is limited to the
|
`comment_logging`, and `numbered_params`, plus the `g1_zero_feed`,
|
||||||
JavaScript host-boundary adapter plus the INI browser smoke harness. Full
|
`arc_radius_mismatch`, `arc_zero_radius`, and `g53_incremental` negative
|
||||||
browser coverage, full SDK coverage, and full machine-session validation remain
|
fixtures. OPFS validation is limited to the JavaScript host-boundary adapter
|
||||||
future work.
|
plus the INI browser smoke harness. Full browser coverage, full SDK coverage,
|
||||||
|
and full machine-session validation remain future work.
|
||||||
|
|
||||||
The current fixture expectations validate standalone behavior against both the
|
The current fixture expectations validate standalone behavior against both the
|
||||||
vendored LinuxCNC source path and an upstream `rs274` side-by-side baseline for
|
vendored LinuxCNC source path and an upstream `rs274` side-by-side baseline for
|
||||||
|
|||||||
@@ -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 __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = dirname(__filename);
|
||||||
const rootDir = resolve(__dirname, "../../..");
|
const rootDir = resolve(__dirname, "../../..");
|
||||||
@@ -66,16 +88,26 @@ for (const fixtureName of fixtureNames) {
|
|||||||
"utf8",
|
"utf8",
|
||||||
).trimEnd();
|
).trimEnd();
|
||||||
|
|
||||||
const output = runProgram(interp, programText);
|
verifyExpectedOutput(fixtureName, runProgram(interp, programText), expectedEvents);
|
||||||
const actualLineSet = new Set(output.split("\n").filter(Boolean));
|
}
|
||||||
const expectedLines = expectedEvents.split("\n").filter(Boolean);
|
|
||||||
|
|
||||||
for (const expectedLine of expectedLines) {
|
const errorFixtureNames = [
|
||||||
assert.equal(
|
"g1_zero_feed",
|
||||||
actualLineSet.has(expectedLine),
|
"arc_radius_mismatch",
|
||||||
true,
|
"arc_zero_radius",
|
||||||
`${fixtureName}: ${expectedLine}`,
|
"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");
|
console.log("interp_wasm_node_smoke=ok");
|
||||||
|
|||||||
Reference in New Issue
Block a user