From ec12b721e8186649b1578b8869590d7997b1662a Mon Sep 17 00:00:00 2001 From: giles Date: Sat, 9 May 2026 05:35:19 +0000 Subject: [PATCH] ocaml: phase 4 Set.Make / Map.Make functor application smoke tests (+3 tests, 572 total) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Functors were already wired through ocaml-make-functor in eval.sx (curried host closure consuming module dicts) but had no explicit tests for the user-defined Ord application path. This commit adds three smoke tests that confirm: module IntOrd = struct let compare a b = a - b end module S = Set.Make (IntOrd) S.elements (fold-add [5;1;3;1;5]) sums to 9 (dedupe + sort) S.mem 2 (S.add 1 (S.add 2 (S.add 3 S.empty))) = true M.cardinal (M.add 1 'a' (M.add 2 'b' M.empty)) = 2 The Ord parameter is properly threaded through the functor body — elements are sorted in compare order and dedupe works. --- lib/ocaml/test.sh | 13 +++++++++++++ plans/ocaml-on-sx.md | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/lib/ocaml/test.sh b/lib/ocaml/test.sh index 2baaaa56..9135631b 100755 --- a/lib/ocaml/test.sh +++ b/lib/ocaml/test.sh @@ -1422,6 +1422,14 @@ cat > "$TMPFILE" << 'EPOCHS' (epoch 5171) (eval "(ocaml-run \"Char.equal \\\"a\\\" \\\"a\\\"\")") +;; ── Set.Make / Map.Make functor application ────────────────── +(epoch 5180) +(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = a - b end ;; module S = Set.Make (IntOrd) ;; let s = List.fold_left (fun s x -> S.add x s) S.empty [5;1;3;1;5] ;; List.fold_left (+) 0 (S.elements s)\")") +(epoch 5181) +(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = a - b end ;; module S = Set.Make (IntOrd) ;; let s = S.add 1 (S.add 2 (S.add 3 S.empty)) ;; S.mem 2 s\")") +(epoch 5182) +(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = a - b end ;; module M = Map.Make (IntOrd) ;; let m = M.add 1 \\\"a\\\" (M.add 2 \\\"b\\\" M.empty) ;; M.cardinal m\")") + EPOCHS OUTPUT=$(timeout 360 "$SX_SERVER" < "$TMPFILE" 2>/dev/null) @@ -2261,6 +2269,11 @@ check 5164 "chop_extension hello.ml" '"hello"' check 5170 "Char.compare b a" '1' check 5171 "Char.equal a a" 'true' +# ── Set.Make / Map.Make functor application ───────────────────── +check 5180 "Set.Make dedupe sum" '9' +check 5181 "Set.Make mem" 'true' +check 5182 "Map.Make cardinal" '2' + TOTAL=$((PASS + FAIL)) if [ $FAIL -eq 0 ]; then echo "ok $PASS/$TOTAL OCaml-on-SX tests passed" diff --git a/plans/ocaml-on-sx.md b/plans/ocaml-on-sx.md index dd2dd8de..bce487b0 100644 --- a/plans/ocaml-on-sx.md +++ b/plans/ocaml-on-sx.md @@ -407,6 +407,13 @@ _Newest first._ binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree * 'a tree`) with insert + in-order traversal. Tests parametric ADT, recursive match, List.append, List.fold_left. +- 2026-05-09 Phase 4 — Set.Make / Map.Make functor application + smoke tests (+3 tests, 572 total). Functors were already wired + through ocaml-make-functor in eval.sx but had no explicit tests + for the user-defined Ord application path. Confirms that + `module S = Set.Make (IntOrd) ;; let s = ... in S.elements s`, + `S.mem 2 s`, and `Map.Make (IntOrd) ;; M.cardinal m` all work end + to end. - 2026-05-09 Phase 6 — Filename module + Char.compare/equal/escaped (+7 tests, 569 total). Filename: basename, dirname, extension, chop_extension, concat, is_relative + dir_sep / current_dir_name /