Verify rewriter and runtime linkage through explicit interfaces

This commit is contained in:
milner committed 2019-04-26 18:12:00 +00:00
1 parent 16fc1d6cee
commit ef4c7899d5
3 files changed
+142 -5

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
#!/bin/sh
set -eu
compiler=${OCAMLC:-ocamlc}
rewriter=$(cd "$(dirname "$1")" && pwd)/$(basename "$1")
library=$(cd "$2" && pwd)
directory=$(mktemp -d)
trap 'rm -rf "$directory"' EXIT HUP INT TERM
cat > "$directory/unit.mli" <<'ML'
type t = { colour : string; label : string }
val colour : t -> string
val set_colour : string -> t -> t
val _colour : (t -> string) * (string -> t -> t)
ML
cat > "$directory/unit.ml" <<'ML'
type t = { colour : string; label : string } [@@fieldglass generate]
ML
cat > "$directory/client.ml" <<'ML'
let () =
let original = Unit.{ colour = "grey"; label = "sample" } in
let changed = Fieldglass.over Unit._colour ~f:String.uppercase_ascii original in
assert (Unit.colour changed = "GREY");
assert (changed.Unit.label = original.Unit.label);
assert (Unit.colour original = "grey")
ML
"$compiler" -c "$directory/unit.mli"
"$compiler" -I "$directory" -ppx "$rewriter" -c "$directory/unit.ml"
"$compiler" -I "$library" -I "$directory" "$library/fieldglass.cma" \
"$directory/unit.cmo" "$directory/client.ml" -o "$directory/client.byte"
"$directory/client.byte"