ocaml: phase 4 open / include (+5 tests, 220 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 57s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 57s
Parser: open Path and include Path top-level decls; Path is Ctor (.Ctor)*. Eval resolves via ocaml-resolve-module-path (same :con-as-module-lookup escape hatch used by :field). open extends the env with the module's bindings; include also merges into the surrounding module's exports (when inside a struct...end). Path resolver lets M.Sub.x work for nested modules. Phase 4 LOC ~165.
This commit is contained in:
@@ -555,6 +555,18 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 716)
|
||||
(eval "(ocaml-run-program \"module Pair = struct let make a b = (a, b) let swap p = match p with | (x, y) -> (y, x) end ;; Pair.swap (Pair.make 1 2)\")")
|
||||
|
||||
;; ── open / include ─────────────────────────────────────────────
|
||||
(epoch 730)
|
||||
(eval "(ocaml-run-program \"module M = struct let x = 42 let f y = y + 1 end ;; open M ;; f x\")")
|
||||
(epoch 731)
|
||||
(eval "(ocaml-run-program \"module Math = struct let pi = 3 let sq x = x * x end ;; module Sphere = struct include Math let area r = 4 * pi * sq r end ;; Sphere.area 2\")")
|
||||
(epoch 732)
|
||||
(eval "(ocaml-run-program \"module M = struct let x = 1 end ;; module N = struct open M let y = x + 10 end ;; N.y\")")
|
||||
(epoch 733)
|
||||
(eval "(ocaml-run-program \"module Math = struct let pi = 3 let sq x = x * x end ;; module Sphere = struct include Math let area r = 4 * pi * sq r end ;; Sphere.pi\")")
|
||||
(epoch 734)
|
||||
(eval "(ocaml-run-program \"module M = struct let x = 1 let y = 2 end ;; module N = struct include M let z = x + y end ;; N.z\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -883,6 +895,13 @@ check 714 "nested module Outer.Inner" '99'
|
||||
check 715 "module rec fact 5" '120'
|
||||
check 716 "module Pair.swap" '("tuple" 2 1)'
|
||||
|
||||
# ── open / include ──────────────────────────────────────────────
|
||||
check 730 "open M; f x" '43'
|
||||
check 731 "include Math; area" '48'
|
||||
check 732 "module open inside" '11'
|
||||
check 733 "Sphere.pi via include" '3'
|
||||
check 734 "include M; N.z = x+y" '3'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user