继续按 align-linuxcnc 约束:补表达式错误源码回归

This commit is contained in:
cnc
2026-06-02 15:54:17 +08:00
parent 7319e18810
commit 4861287138
4 changed files with 24 additions and 1 deletions

View File

@@ -571,6 +571,25 @@ if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
echo "expected linuxcnc_infinite_expression_error.ngc to fail" >&2
exit 1
fi
# Source basis: LinuxCNC src/emc/rs274ngc/interp_execute.cc
# execute_binary1() rejects divide-by-zero and negative base
# non-integer power expression operators.
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_divide_by_zero_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_divide_by_zero_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_divide_by_zero_error.err"; then
echo "expected linuxcnc_divide_by_zero_error.ngc to fail" >&2
exit 1
fi
grep -q "Attempt to divide by zero" \
"$output_dir/cnc_sim_linuxcnc_source_divide_by_zero_error.err"
if CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_negative_power_error.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_negative_power_error.json" 2>"$output_dir/cnc_sim_linuxcnc_source_negative_power_error.err"; then
echo "expected linuxcnc_negative_power_error.ngc to fail" >&2
exit 1
fi
grep -q "Attempt to raise negative to non integer power" \
"$output_dir/cnc_sim_linuxcnc_source_negative_power_error.err"
CNC_SIM_RS274_FILE_MODE=1 CNC_SIM_RS274_VAR="$var_file" \
"$build_dir/linuxcnc_rs274_source_dump" tests/gcode/linuxcnc_value_returned.ngc \
>"$output_dir/cnc_sim_linuxcnc_source_value_returned.json"