继续按 align-linuxcnc 约束:补极坐标变体源码覆盖,测试通过

This commit is contained in:
cnc
2026-06-02 22:20:03 +08:00
parent 84fdc8a1c5
commit 030074b8c5
3 changed files with 31 additions and 0 deletions

View File

@@ -555,6 +555,9 @@ CNC_SIM_RS274_VAR="$var_file" \
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_polar_coordinates.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_polar_coordinates.json"
CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_polar_coordinate_variants.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_polar_coordinate_variants.json"
polar_coordinate_error_cases=(
"linuxcnc_polar_g18_error|Cannot use polar coordinate except in G17 plane"
"linuxcnc_polar_with_x_error|Cannot specify both polar coordinate and X word"
@@ -2122,6 +2125,25 @@ if len(polar_linear_events) != len(expected_polar_linear_ends) or any(
]
raise SystemExit(f"unexpected source-linked polar-coordinate endpoints: {polar_linear_ends!r}")
polar_coordinate_variants = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_polar_coordinate_variants.json").read_text())
polar_variant_linear_events = [
event
for event in polar_coordinate_variants
if event["type"] == "linear-feed"
]
expected_polar_variant_ends = [(3, 6, 8), (4, 10, 0), (6, 15, 0), (7, 0, 15)]
if len(polar_variant_linear_events) != len(expected_polar_variant_ends) or any(
event["line"] != line or
abs(event["end"]["x"] - x) > 1e-9 or
abs(event["end"]["y"] - y) > 1e-9
for event, (line, x, y) in zip(polar_variant_linear_events, expected_polar_variant_ends)
):
polar_variant_linear_ends = [
(event["line"], event["end"]["x"], event["end"]["y"])
for event in polar_variant_linear_events
]
raise SystemExit(f"unexpected source-linked polar-coordinate variant endpoints: {polar_variant_linear_ends!r}")
predefined = json.loads((OUTPUT_DIR / "cnc_sim_linuxcnc_source_predefined_positions.json").read_text())
predefined_rapids = [
(