# APL conformance config — sourced by lib/guest/conformance.sh.

LANG_NAME=apl
MODE=counters
COUNTERS_PASS=apl-test-pass
COUNTERS_FAIL=apl-test-fail
TIMEOUT_PER_SUITE=300

PRELOADS=(
  spec/stdlib.sx
  lib/r7rs.sx
  lib/apl/runtime.sx
  lib/apl/tokenizer.sx
  lib/apl/parser.sx
  lib/apl/transpile.sx
  lib/apl/test-harness.sx
)

SUITES=(
  "structural:lib/apl/tests/structural.sx"
  "operators:lib/apl/tests/operators.sx"
  "dfn:lib/apl/tests/dfn.sx"
  "tradfn:lib/apl/tests/tradfn.sx"
  "valence:lib/apl/tests/valence.sx"
  "programs:lib/apl/tests/programs.sx"
  "system:lib/apl/tests/system.sx"
  "idioms:lib/apl/tests/idioms.sx"
  "eval-ops:lib/apl/tests/eval-ops.sx"
  "pipeline:lib/apl/tests/pipeline.sx"
)

emit_scoreboard_json() {
  local n=${#GC_NAMES[@]} i sep
  printf '{\n'
  printf '  "suites": {\n'
  for ((i=0; i<n; i++)); do
    sep=","; [ $i -eq $((n-1)) ] && sep=""
    printf '    "%s": {"pass": %d, "fail": %d}%s\n' \
      "${GC_NAMES[$i]}" "${GC_PASS[$i]}" "${GC_FAIL[$i]}" "$sep"
  done
  printf '  },\n'
  printf '  "total_pass": %d,\n' "$GC_TOTAL_PASS"
  printf '  "total_fail": %d,\n' "$GC_TOTAL_FAIL"
  printf '  "total": %d\n' "$GC_TOTAL"
  printf '}\n'
}

emit_scoreboard_md() {
  local n=${#GC_NAMES[@]} i
  printf '# APL Conformance Scoreboard\n\n'
  printf '_Generated by `lib/apl/conformance.sh`_\n\n'
  printf '| Suite | Pass | Fail | Total |\n'
  printf '|-------|-----:|-----:|------:|\n'
  for ((i=0; i<n; i++)); do
    printf '| %s | %d | %d | %d |\n' \
      "${GC_NAMES[$i]}" "${GC_PASS[$i]}" "${GC_FAIL[$i]}" "${GC_TOTAL_S[$i]}"
  done
  printf '| **Total** | **%d** | **%d** | **%d** |\n' "$GC_TOTAL_PASS" "$GC_TOTAL_FAIL" "$GC_TOTAL"
  printf '\n'
  printf '## Notes\n\n'
  printf '%s\n' '- Suites use the standard `apl-test name got expected` framework loaded against `lib/apl/runtime.sx` + `lib/apl/transpile.sx`.'
  printf '%s\n' '- `lib/apl/tests/parse.sx` and `lib/apl/tests/scalar.sx` use their own self-contained frameworks and are excluded from this scoreboard.'
}
