ocaml: phase 6 expanded stdlib (+15 tests, 319 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 54s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 54s
List: concat/flatten, init, find/find_opt, partition, mapi/iteri, assoc/assoc_opt. Option: iter/fold/to_list. Result: get_ok/get_error/ map_error/to_option. Fixed skip-to-boundary! in parser to track let..in / begin..end / struct..end / for/while..done nesting via a depth counter — without this, nested-let inside a top-level decl body trips over the decl-boundary detector. Stdlib functions like List.init / mapi / iteri use begin..end to make their nested-let intent explicit.
This commit is contained in:
@@ -764,6 +764,40 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 1323)
|
||||
(eval "(ocaml-run-program \"exception E of string ;; try raise (E \\\"oops\\\") with | E s -> s\")")
|
||||
|
||||
;; ── Phase 6 expanded stdlib (List/Option/Result extensions) ───
|
||||
(epoch 1400)
|
||||
(eval "(ocaml-run \"List.concat [[1;2];[3];[4;5]]\")")
|
||||
(epoch 1401)
|
||||
(eval "(ocaml-run \"List.init 5 (fun i -> i * 10)\")")
|
||||
(epoch 1402)
|
||||
(eval "(ocaml-run \"List.find_opt (fun x -> x > 2) [1;2;3;4]\")")
|
||||
(epoch 1403)
|
||||
(eval "(ocaml-run \"List.find_opt (fun x -> x > 99) [1;2;3]\")")
|
||||
(epoch 1404)
|
||||
(eval "(ocaml-run \"List.mapi (fun i x -> i + x) [10;20;30]\")")
|
||||
(epoch 1405)
|
||||
(eval "(ocaml-run \"List.partition (fun x -> x > 2) [1;2;3;4]\")")
|
||||
(epoch 1406)
|
||||
(eval "(ocaml-run \"List.assoc 2 [(1, \\\"a\\\"); (2, \\\"b\\\"); (3, \\\"c\\\")]\")")
|
||||
(epoch 1407)
|
||||
(eval "(ocaml-run \"List.assoc_opt 99 [(1, \\\"a\\\")]\")")
|
||||
|
||||
(epoch 1410)
|
||||
(eval "(ocaml-run \"Option.fold 0 (fun x -> x * 10) (Some 7)\")")
|
||||
(epoch 1411)
|
||||
(eval "(ocaml-run \"Option.fold 0 (fun x -> x * 10) None\")")
|
||||
(epoch 1412)
|
||||
(eval "(ocaml-run \"Option.to_list (Some 7)\")")
|
||||
(epoch 1413)
|
||||
(eval "(ocaml-run \"Option.to_list None\")")
|
||||
|
||||
(epoch 1420)
|
||||
(eval "(ocaml-run \"Result.get_ok (Ok 42)\")")
|
||||
(epoch 1421)
|
||||
(eval "(ocaml-run \"Result.to_option (Ok 1)\")")
|
||||
(epoch 1422)
|
||||
(eval "(ocaml-run \"Result.map_error (fun e -> e + 1) (Error 5)\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 180 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1210,6 +1244,25 @@ check 1321 "exception arg" '("exception-def" "MyExn"'
|
||||
check 1322 "raise+catch with arg" '5'
|
||||
check 1323 "raise+catch string arg" '"oops"'
|
||||
|
||||
# ── Phase 6 expanded stdlib ─────────────────────────────────────
|
||||
check 1400 "List.concat" '(1 2 3 4 5)'
|
||||
check 1401 "List.init" '(0 10 20 30 40)'
|
||||
check 1402 "List.find_opt found" '("Some" 3)'
|
||||
check 1403 "List.find_opt missing" '("None")'
|
||||
check 1404 "List.mapi" '(10 21 32)'
|
||||
check 1405 "List.partition" '("tuple" (3 4) (1 2))'
|
||||
check 1406 "List.assoc" '"b"'
|
||||
check 1407 "List.assoc_opt missing" '("None")'
|
||||
|
||||
check 1410 "Option.fold Some" '70'
|
||||
check 1411 "Option.fold None" '0'
|
||||
check 1412 "Option.to_list Some" '(7)'
|
||||
check 1413 "Option.to_list None" '()'
|
||||
|
||||
check 1420 "Result.get_ok" '42'
|
||||
check 1421 "Result.to_option Ok" '("Some" 1)'
|
||||
check 1422 "Result.map_error" '("Error" 6)'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user