ocaml: phase 6 Map.Make / Set.Make functors (+4 tests, 418 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
Both written in OCaml inside lib/ocaml/runtime.sx:
module Map = struct module Make (Ord) = struct
let empty = []
let add k v m = ... (* sorted insert via Ord.compare *)
let find_opt / find / mem / remove / bindings / cardinal
end end
module Set = struct module Make (Ord) = struct
let empty = []
let mem / add / remove / elements / cardinal
end end
Sorted association list / sorted list backing — linear ops but
correct. Strong substrate-validation: Map.Make is a non-trivial
functor implemented entirely on top of the OCaml-on-SX evaluator.
This commit is contained in:
@@ -1024,6 +1024,16 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 3204)
|
||||
(eval "(ocaml-run \"Sys.executable_name\")")
|
||||
|
||||
;; ── Map.Make / Set.Make functors ──────────────────────────────
|
||||
(epoch 3300)
|
||||
(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = compare a b end ;; module IntMap = Map.Make(IntOrd) ;; let m = IntMap.add 1 \\\"a\\\" IntMap.empty ;; let m = IntMap.add 2 \\\"b\\\" m ;; IntMap.find 1 m\")")
|
||||
(epoch 3301)
|
||||
(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = compare a b end ;; module IntMap = Map.Make(IntOrd) ;; IntMap.cardinal (IntMap.add 1 \\\"a\\\" (IntMap.add 2 \\\"b\\\" IntMap.empty))\")")
|
||||
(epoch 3302)
|
||||
(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = compare a b end ;; module IntSet = Set.Make(IntOrd) ;; IntSet.elements (IntSet.add 3 (IntSet.add 1 (IntSet.add 2 IntSet.empty)))\")")
|
||||
(epoch 3303)
|
||||
(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = compare a b end ;; module IntSet = Set.Make(IntOrd) ;; IntSet.mem 2 (IntSet.add 3 (IntSet.add 1 (IntSet.add 2 IntSet.empty)))\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 180 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1620,6 +1630,12 @@ check 3202 "Sys.unix" 'true'
|
||||
check 3203 "Sys.win32" 'false'
|
||||
check 3204 "Sys.executable_name" '"ocaml-on-sx"'
|
||||
|
||||
# ── Map.Make / Set.Make ────────────────────────────────────────
|
||||
check 3300 "Map.find via functor" '"a"'
|
||||
check 3301 "Map.cardinal" '2'
|
||||
check 3302 "Set.elements sorted" '(1 2 3)'
|
||||
check 3303 "Set.mem" 'true'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user