Local judge and stress-testing toolchain for MoonBit: testlib-style strict checkers, seeded generators, and a subprocess runner with timeout.
2026 MoonBit Hackathon entry · direction: developer tools · November season.中文文档:README.zh-CN.md
moon add xcc-ordinary/moonjudgemoon test --target wasm # full regression suite (87 tests)
moon test --target wasm-gc # pure-logic packages (78 tests)
# Self-contained demo: catches a planted bug and saves the counterexample.
moon run --target wasm cmd/moonjudge -- demo
# Judge a solution: validate format, or compare against a reference answer.
moon run --target wasm cmd/moonjudge -- judge --prog "cmd.exe /c echo 42" --checker ints
moon run --target wasm cmd/moonjudge -- judge --prog "sol.exe" --answer ans.txt --checker doubles
# Stress-test external programs (generator receives the round seed as its last arg).
moon run --target wasm cmd/moonjudge -- stress \
--gen "gen.exe" --brute "brute.exe" --fast "fast.exe" --rounds 100 --seed 42
# Batch-judge a program over a directory of cases (case.in + case.ans).
moon run --target wasm cmd/moonjudge -- batch --prog "sol.exe" --tests ./tests --checker intsStress demo: sum 1..n, buggy fast solution (wrong when n % 7 == 0).
Counterexample at round 0 (seed=6255019084209693600):
input = 0
brute = 0
fast = -1
reason= exact mismatch
Saved counterexample to moonjudge-failure/ (replay with the seed).| Package | Responsibility |
|---|---|
| checker | Strict format/bounds validation core (testlib-style), error + verdict types |
| checkers | Ready-made checkers composed from the core |
| gen | Reproducible test-data generation |
| runner | Subprocess execution, timeout, capture, verdict mapping |
| stress | Reproducible brute-vs-fast comparison loop + counterexample capture |
| cmd/moonjudge | CLI entry: demo / judge / stress / batch |
| examples | Dogfooding: real CSP-style problem stress cases |
| probe | Minimal subprocess capability probe |
check_int_sequence: 4000000 ints in ~0.15s (~27 million integers / second)
check_unordered_ints: 30000 ints (reversed) in ~0.003sinput = 2 -4 -2 (n = 2, array [-4, -2])
brute = -2 (correct: max subarray is the single element -2)
buggy = 0 (wrong: Kadane clamped to 0 on an all-negative array)input = 8 1 0 0 1 3 3 4 4 4 (n = 8, target = 1, sorted array)
brute = 2 (correct lower_bound: first index with a[i] >= 1)
buggy = 3 (wrong: upper_bound, first index with a[i] > 1)Install
Download zipLocal judge and stress-testing toolchain for MoonBit: testlib-style strict checkers, seeded generators, and a subprocess runner with timeout.