参考所有分组:补 O-word 状态参数 native 覆盖,测试通过

This commit is contained in:
cnc
2026-06-03 00:19:16 +08:00
parent 3df61e8da5
commit e3d47e8267
2 changed files with 124 additions and 1 deletions

View File

@@ -641,6 +641,14 @@ for case in "${oword_execution_error_cases[@]}"; do
grep -Fq "$expected" "$output_dir/cnc_sim_linuxcnc_$fixture.err"
done
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_oword_control_flow.ngc >"$output_dir/cnc_sim_linuxcnc_oword_control_flow.json"
# Source basis: LinuxCNC src/emc/rs274ngc/interp_o_word.cc updates
# subroutine return values and call frames; interp_read.cc read_parameter()
# handles EXISTS[] word-value checks and lowercase numeric O-words in file mode.
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_value_returned.ngc >"$output_dir/cnc_sim_linuxcnc_value_returned.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_call_level.ngc >"$output_dir/cnc_sim_linuxcnc_call_level.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_exists_word_value.ngc >"$output_dir/cnc_sim_linuxcnc_exists_word_value.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_lowercase_numeric_oword.ngc >"$output_dir/cnc_sim_linuxcnc_lowercase_numeric_oword.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_m98_mixed_styles_variables.ngc >"$output_dir/cnc_sim_linuxcnc_m98_mixed_styles_variables.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_named_parameter_exists.ngc >"$output_dir/cnc_sim_linuxcnc_named_parameter_exists.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_indexed_parameters.ngc >"$output_dir/cnc_sim_linuxcnc_indexed_parameters.json"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" "$build_dir/linuxcnc_rs274_dump" tests/gcode/linuxcnc_named_parameter_normalization.ngc >"$output_dir/cnc_sim_linuxcnc_named_parameter_normalization.json"
@@ -1623,6 +1631,116 @@ if any(
):
raise SystemExit("LinuxCNC named O-word return should skip remaining subprogram body")
value_returned = load("cnc_sim_linuxcnc_value_returned.json")
if not any(
event["type"] == "linear-feed" and
event["line"] == 11 and
event["end"]["x"] == 1
for event in value_returned
):
raise SystemExit("missing LinuxCNC initial #<_value_returned> clear branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 15 and
event["end"]["y"] == 1
for event in value_returned
):
raise SystemExit("missing LinuxCNC #<_value_returned> endsub[value] branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 19 and
event["end"]["z"] == 1
for event in value_returned
):
raise SystemExit("missing LinuxCNC #<_value_returned> cleared-procedure branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 23 and
event["end"]["a"] == 1
for event in value_returned
):
raise SystemExit("missing LinuxCNC #<_value_returned> return[value] branch motion")
call_level = load("cnc_sim_linuxcnc_call_level.json")
if not any(
event["type"] == "linear-feed" and
event["line"] == 15 and
event["end"]["x"] == 1
for event in call_level
):
raise SystemExit("missing LinuxCNC main-program #<_call_level> branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 8 and
event["end"]["y"] == 1
for event in call_level
):
raise SystemExit("missing LinuxCNC outer O-word #<_call_level> branch motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 3 and
event["end"]["z"] == 1
for event in call_level
):
raise SystemExit("missing LinuxCNC inner O-word #<_call_level>/#<_remap_level> branch motion")
exists_word_value = load("cnc_sim_linuxcnc_exists_word_value.json")
if not any(
event["type"] == "rapid" and
event["line"] == 2 and
event["end"]["x"] == 1 and
event["end"]["y"] == 0 and
event["end"]["z"] == 1 and
event["end"]["a"] == 0
for event in exists_word_value
):
raise SystemExit("missing LinuxCNC direct EXISTS word-value motion")
if not any(
event["type"] == "rapid" and
event["line"] == 5 and
event["end"]["x"] == 1 and
event["end"]["y"] == 0 and
event["end"]["z"] == 0
for event in exists_word_value
):
raise SystemExit("missing LinuxCNC indirect EXISTS word-value motion")
lowercase_numeric_oword = load("cnc_sim_linuxcnc_lowercase_numeric_oword.json")
if not any(
event["type"] == "linear-feed" and
event["line"] == 9 and
event["end"]["x"] == 6
for event in lowercase_numeric_oword
):
raise SystemExit("missing LinuxCNC lowercase numeric O-word return[value] motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 11 and
event["end"]["y"] == 7
for event in lowercase_numeric_oword
):
raise SystemExit("missing LinuxCNC lowercase numeric O-word endsub[value] motion")
m98_mixed_styles = load("cnc_sim_linuxcnc_m98_mixed_styles_variables.json")
if not any(
event["type"] == "linear-feed" and
event["line"] == 5 and
event["end"]["x"] == 13.01 and
event["end"]["y"] == 13.3 and
event["end"]["z"] == 13.31
for event in m98_mixed_styles
):
raise SystemExit("missing LinuxCNC M98 mixed-style global-parameter motion")
if not any(
event["type"] == "linear-feed" and
event["line"] == 10 and
event["end"]["a"] == 42.01 and
event["end"]["b"] == 42.3 and
event["end"]["c"] == 13.31
for event in m98_mixed_styles
):
raise SystemExit("missing LinuxCNC O-word mixed-style local-parameter motion")
oword_flow = load("cnc_sim_linuxcnc_oword_control_flow.json")
if not any(event["type"] == "linear-feed" and event["line"] == 7 and event["end"]["x"] == 2 for event in oword_flow):
raise SystemExit("missing LinuxCNC O-word elseif branch motion")
@@ -1910,6 +2028,11 @@ echo "dumped $output_dir/cnc_sim_linuxcnc_oword_subprogram.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_named_oword_subprogram.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_m98_subprogram.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_oword_control_flow.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_value_returned.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_call_level.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_exists_word_value.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_lowercase_numeric_oword.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_m98_mixed_styles_variables.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_named_parameter_exists.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_indexed_parameters.json"
echo "dumped $output_dir/cnc_sim_linuxcnc_named_parameter_normalization.json"