Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
Phase 3 — bidirectional type checker — is fully ticked (short-decl
was already implemented). Phase 4 starts here.
lib/go/eval.sx single judgment:
(go-eval ENV EXPR) → VALUE | (list :eval-error TAG ...)
ENV is an association list of (NAME VALUE) bindings — same shape as
the type checker's ctx, but the entries are runtime values. Values
are represented directly in SX: integers/floats as SX numbers,
strings as SX strings, booleans as true/false, nil as nil. Composite
values (slices/maps/structs/pointers/channels) arrive in later slices.
First-slice coverage:
* go-env-empty / -lookup / -extend
* Literal decoding:
decimal (with underscores)
hex (0x.. / 0X..)
oct (0o.. / 0O..)
bin (0b.. / 0B..)
via go-hex-digit-value (explicit char equality — SX's nth on
strings returns single-char strings, not numeric codes; the
arithmetic-on-char-codes pattern from the OCaml kernel ports
doesn't work here).
* Identifier lookup with predeclared true / false / nil.
* Binops: + - * / and the six comparison ops and && / ||.
* Errors as (:eval-error TAG ...) sentinels.
Statements (block / return / short-decl / assign), control flow
(if / for), and function application / closures arrive in subsequent
slices.
eval 25/25, total 402/402.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
139 lines
3.3 KiB
Bash
Executable File
139 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Go-on-SX conformance runner.
|
|
#
|
|
# Loads every Go-on-SX test suite via the epoch protocol, collects
|
|
# pass/fail counts, and writes lib/go/scoreboard.json + .md.
|
|
#
|
|
# Usage:
|
|
# bash lib/go/conformance.sh # run all suites
|
|
# bash lib/go/conformance.sh -v # verbose per-suite
|
|
|
|
set -uo pipefail
|
|
cd "$(git rev-parse --show-toplevel)"
|
|
|
|
SX_SERVER="${SX_SERVER:-hosts/ocaml/_build/default/bin/sx_server.exe}"
|
|
if [ ! -x "$SX_SERVER" ]; then
|
|
SX_SERVER="/root/rose-ash/hosts/ocaml/_build/default/bin/sx_server.exe"
|
|
fi
|
|
if [ ! -x "$SX_SERVER" ]; then
|
|
echo "ERROR: sx_server.exe not found." >&2
|
|
exit 1
|
|
fi
|
|
|
|
VERBOSE="${1:-}"
|
|
TMPFILE=$(mktemp)
|
|
OUTFILE=$(mktemp)
|
|
trap "rm -f $TMPFILE $OUTFILE" EXIT
|
|
|
|
# Each suite: name | pass-counter | total-counter
|
|
SUITES=(
|
|
"lex|go-test-pass|go-test-count"
|
|
"parse|go-parse-test-pass|go-parse-test-count"
|
|
"types|go-types-test-pass|go-types-test-count"
|
|
"eval|go-eval-test-pass|go-eval-test-count"
|
|
)
|
|
|
|
cat > "$TMPFILE" <<'EPOCHS'
|
|
(epoch 1)
|
|
(load "lib/guest/lex.sx")
|
|
(load "lib/guest/ast.sx")
|
|
(load "lib/guest/pratt.sx")
|
|
(load "lib/go/lex.sx")
|
|
(load "lib/go/parse.sx")
|
|
(load "lib/go/types.sx")
|
|
(load "lib/go/eval.sx")
|
|
(load "lib/go/tests/lex.sx")
|
|
(load "lib/go/tests/parse.sx")
|
|
(load "lib/go/tests/types.sx")
|
|
(load "lib/go/tests/eval.sx")
|
|
EPOCHS
|
|
|
|
idx=0
|
|
for entry in "${SUITES[@]}"; do
|
|
name="${entry%%|*}"
|
|
pass_var=$(echo "$entry" | awk -F'|' '{print $2}')
|
|
total_var=$(echo "$entry" | awk -F'|' '{print $3}')
|
|
epoch=$((100 + idx))
|
|
echo "(epoch $epoch)" >> "$TMPFILE"
|
|
echo "(eval \"(list $pass_var $total_var)\")" >> "$TMPFILE"
|
|
idx=$((idx + 1))
|
|
done
|
|
|
|
"$SX_SERVER" < "$TMPFILE" > "$OUTFILE" 2>&1
|
|
|
|
parse_pair() {
|
|
local epoch="$1"
|
|
local line
|
|
line=$(grep -A1 "^(ok-len $epoch " "$OUTFILE" | tail -1)
|
|
echo "$line" | sed -E 's/[()]//g'
|
|
}
|
|
|
|
TOTAL_PASS=0
|
|
TOTAL_COUNT=0
|
|
JSON_SUITES=""
|
|
MD_ROWS=""
|
|
|
|
idx=0
|
|
for entry in "${SUITES[@]}"; do
|
|
name="${entry%%|*}"
|
|
epoch=$((100 + idx))
|
|
pair=$(parse_pair "$epoch")
|
|
pass=$(echo "$pair" | awk '{print $1}')
|
|
count=$(echo "$pair" | awk '{print $2}')
|
|
if [ -z "$pass" ] || [ -z "$count" ]; then
|
|
pass=0
|
|
count=0
|
|
fi
|
|
TOTAL_PASS=$((TOTAL_PASS + pass))
|
|
TOTAL_COUNT=$((TOTAL_COUNT + count))
|
|
status="ok"
|
|
marker="✅"
|
|
if [ "$pass" != "$count" ]; then
|
|
status="fail"
|
|
marker="❌"
|
|
fi
|
|
if [ "$VERBOSE" = "-v" ]; then
|
|
printf " %-12s %s/%s\n" "$name" "$pass" "$count"
|
|
fi
|
|
if [ -n "$JSON_SUITES" ]; then JSON_SUITES+=","; fi
|
|
JSON_SUITES+=$'\n '
|
|
JSON_SUITES+="{\"name\":\"$name\",\"pass\":$pass,\"total\":$count,\"status\":\"$status\"}"
|
|
MD_ROWS+="| $marker | $name | $pass | $count |"$'\n'
|
|
idx=$((idx + 1))
|
|
done
|
|
|
|
printf '\nGo-on-SX conformance: %d / %d\n' "$TOTAL_PASS" "$TOTAL_COUNT"
|
|
|
|
cat > lib/go/scoreboard.json <<JSON
|
|
{
|
|
"language": "go",
|
|
"total_pass": $TOTAL_PASS,
|
|
"total": $TOTAL_COUNT,
|
|
"suites": [$JSON_SUITES,
|
|
{"name":"runtime","pass":0,"total":0,"status":"pending"},
|
|
{"name":"stdlib","pass":0,"total":0,"status":"pending"},
|
|
{"name":"e2e","pass":0,"total":0,"status":"pending"}
|
|
]
|
|
}
|
|
JSON
|
|
|
|
cat > lib/go/scoreboard.md <<MD
|
|
# Go-on-SX Scoreboard
|
|
|
|
**Total: ${TOTAL_PASS} / ${TOTAL_COUNT} tests passing**
|
|
|
|
| | Suite | Pass | Total |
|
|
|---|---|---|---|
|
|
$MD_ROWS| ⬜ | runtime | 0 | 0 |
|
|
| ⬜ | stdlib | 0 | 0 |
|
|
| ⬜ | e2e | 0 | 0 |
|
|
|
|
Generated by \`lib/go/conformance.sh\`.
|
|
MD
|
|
|
|
if [ "$TOTAL_PASS" -eq "$TOTAL_COUNT" ]; then
|
|
exit 0
|
|
else
|
|
exit 1
|
|
fi
|