# Go-on-SX conformance config — sourced by lib/guest/conformance.sh.
#
# Like erlang: suites load into one session and each exposes a pass counter and
# a *count* (total) counter, not a fail counter. dict mode fits — each runner is
# a dict literal computing :failed as count - pass.

LANG_NAME=go
MODE=dict

PRELOADS=(
  lib/guest/lex.sx
  lib/guest/ast.sx
  lib/guest/pratt.sx
  lib/go/lex.sx
  lib/go/parse.sx
  lib/go/types.sx
  lib/go/sched.sx
  lib/go/eval.sx
  lib/go/std/strings.sx
  lib/go/std/strconv.sx
)

# name:file:(runner) — runner is a dict literal {:passed :failed :total}.
SUITES=(
  "lex:lib/go/tests/lex.sx:{:passed go-test-pass :failed (- go-test-count go-test-pass) :total go-test-count}"
  "parse:lib/go/tests/parse.sx:{:passed go-parse-test-pass :failed (- go-parse-test-count go-parse-test-pass) :total go-parse-test-count}"
  "types:lib/go/tests/types.sx:{:passed go-types-test-pass :failed (- go-types-test-count go-types-test-pass) :total go-types-test-count}"
  "eval:lib/go/tests/eval.sx:{:passed go-eval-test-pass :failed (- go-eval-test-count go-eval-test-pass) :total go-eval-test-count}"
  "runtime:lib/go/tests/runtime.sx:{:passed go-rt-test-pass :failed (- go-rt-test-count go-rt-test-pass) :total go-rt-test-count}"
  "stdlib:lib/go/tests/stdlib.sx:{:passed go-std-test-pass :failed (- go-std-test-count go-std-test-pass) :total go-std-test-count}"
  "e2e:lib/go/tests/e2e.sx:{:passed go-e2e-test-pass :failed (- go-e2e-test-count go-e2e-test-pass) :total go-e2e-test-count}"
)

# Preserve the historical scoreboard schema so consumers of
# lib/go/scoreboard.json keep working.
emit_scoreboard_json() {
  local n=${#GC_NAMES[@]} i status
  printf '{\n'
  printf '  "language": "go",\n'
  printf '  "total_pass": %d,\n' "$GC_TOTAL_PASS"
  printf '  "total": %d,\n' "$GC_TOTAL"
  printf '  "suites": ['
  for ((i=0; i<n; i++)); do
    [ "$i" -gt 0 ] && printf ','
    status="ok"; [ "${GC_FAIL[$i]}" -gt 0 ] && status="fail"
    printf '\n    {"name":"%s","pass":%d,"total":%d,"status":"%s"}' \
      "${GC_NAMES[$i]}" "${GC_PASS[$i]}" "${GC_TOTAL_S[$i]}" "$status"
  done
  printf '\n  ]\n'
  printf '}\n'
}

emit_scoreboard_md() {
  local n=${#GC_NAMES[@]} i marker
  printf '# Go-on-SX Scoreboard\n\n'
  printf '**Total: %d / %d tests passing**\n\n' "$GC_TOTAL_PASS" "$GC_TOTAL"
  printf '|  | Suite | Pass | Total |\n'
  printf '|---|---|---|---|\n'
  for ((i=0; i<n; i++)); do
    marker="✅"; [ "${GC_FAIL[$i]}" -gt 0 ] && marker="❌"
    printf '| %s | %s | %d | %d |\n' \
      "$marker" "${GC_NAMES[$i]}" "${GC_PASS[$i]}" "${GC_TOTAL_S[$i]}"
  done
  printf '\nGenerated by `lib/go/conformance.sh`.\n'
}
