ocaml: phase 1 top-level decls (+9 tests, 104 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s
ocaml-parse-program: program = decls + bare exprs, ;;-separated. Each decl is (:def …), (:def-rec …), or (:expr …). Body parsing re-feeds the source slice through ocaml-parse — shared-state refactor deferred.
This commit is contained in:
@@ -260,6 +260,26 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 260)
|
||||
(eval "(ocaml-parse \"begin 1 + 2 end\")")
|
||||
|
||||
;; ── Top-level decls ────────────────────────────────────────────
|
||||
(epoch 270)
|
||||
(eval "(ocaml-parse-program \"let x = 1\")")
|
||||
(epoch 271)
|
||||
(eval "(ocaml-parse-program \"let x = 1 ;;\")")
|
||||
(epoch 272)
|
||||
(eval "(ocaml-parse-program \"let f x = x + 1\")")
|
||||
(epoch 273)
|
||||
(eval "(ocaml-parse-program \"let rec fact n = if n = 0 then 1 else n * fact (n - 1)\")")
|
||||
(epoch 274)
|
||||
(eval "(ocaml-parse-program \"let x = 1 let y = 2\")")
|
||||
(epoch 275)
|
||||
(eval "(ocaml-parse-program \"1 + 2 ;;\")")
|
||||
(epoch 276)
|
||||
(eval "(ocaml-parse-program \"let x = 1 ;; let y = 2 ;; x + y\")")
|
||||
(epoch 277)
|
||||
(eval "(len (ocaml-parse-program \"let x = 1 ;; let y = 2 ;; x + y\"))")
|
||||
(epoch 278)
|
||||
(eval "(ocaml-parse-program \"\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -414,6 +434,17 @@ check 257 "parse let f x y =" '("let" "f" ("x" "y")'
|
||||
|
||||
check 260 "parse begin/end" '("op" "+" ("int" 1) ("int" 2))'
|
||||
|
||||
# ── Top-level decls ─────────────────────────────────────────────
|
||||
check 270 "program: let x = 1" '("program" ("def" "x" () ("int" 1)))'
|
||||
check 271 "program: let x = 1 ;;" '("program" ("def" "x" () ("int" 1)))'
|
||||
check 272 "program: let f x = x+1" '("program" ("def" "f" ("x") ("op" "+"'
|
||||
check 273 "program: let rec fact" '("def-rec" "fact" ("n")'
|
||||
check 274 "program: two decls" '("def" "x" () ("int" 1)) ("def" "y"'
|
||||
check 275 "program: bare expr" '("program" ("expr" ("op" "+" ("int" 1) ("int" 2))))'
|
||||
check 276 "program: mixed decls + expr" '("def" "y" () ("int" 2)) ("expr"'
|
||||
check 277 "program: 4 forms incl head" '4'
|
||||
check 278 "program: empty" '("program")'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user