Gate‑C(Core): normalize exit code for JSON file/pipe (rc mirrors return); add quick smokes (file/pipe parity).

This commit is contained in:
nyash-codex
2025-11-01 19:42:20 +09:00
parent e74fe8d3b0
commit aa6cd566e8
4 changed files with 120 additions and 5 deletions

View File

@ -0,0 +1,29 @@
#!/bin/bash
# gate_c_parity_file_vm.sh — GateC (file) exit-code mirrors return (quick)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$SCRIPT_DIR/../../../../../.." && pwd)"
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"
require_env || exit 2
json_path="/tmp/ny_gatec_parity_$$.json"
cat >"$json_path" <<'JSON'
{"version":0,"kind":"Program","body":[{"type":"Return","expr":{"type":"Int","value":42}}]}
JSON
set +e
"$ROOT/target/release/nyash" --json-file "$json_path" >/dev/null 2>&1
rc=$?
set -e
rm -f "$json_path"
if [ $rc -eq 42 ]; then
echo "[PASS] gate_c_parity_file_vm"
exit 0
else
echo "[FAIL] gate_c_parity_file_vm: expected rc=42 got $rc" >&2
exit 1
fi

View File

@ -0,0 +1,24 @@
#!/bin/bash
# gate_c_parity_pipe_vm.sh — GateC (stdin pipe) exit-code mirrors return (quick)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$SCRIPT_DIR/../../../../../.." && pwd)"
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"
require_env || exit 2
payload='{"version":0,"kind":"Program","body":[{"type":"Return","expr":{"type":"Int","value":9}}]}'
set +e
echo "$payload" | "$ROOT/target/release/nyash" --ny-parser-pipe >/dev/null 2>&1
rc=$?
set -e
if [ $rc -eq 9 ]; then
echo "[PASS] gate_c_parity_pipe_vm"
exit 0
else
echo "[FAIL] gate_c_parity_pipe_vm: expected rc=9 got $rc" >&2
exit 1
fi