This is an automated email from the git hooks/post-receive script.

treinen pushed a commit to branch master
in repository ocaml-visitors.

commit b1050ddf45a2b3705f63cbd674d27770faa2f9b1
Author: Ralf Treinen <trei...@irif.fr>
Date:   Wed May 24 16:44:38 2017 +0200

    start on test case
---
 debian/tests/Makefile |  5 +++++
 debian/tests/expr.ml  | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/debian/tests/Makefile b/debian/tests/Makefile
new file mode 100644
index 0000000..04e821b
--- /dev/null
+++ b/debian/tests/Makefile
@@ -0,0 +1,5 @@
+expr.native expr.byte: expr.ml
+       ocamlbuild -use-ocamlfind -pkgs 'visitors.ppx,visitors.runtime' $@
+
+clean:
+       -ocamlbuild -clean
diff --git a/debian/tests/expr.ml b/debian/tests/expr.ml
new file mode 100644
index 0000000..b0c6117
--- /dev/null
+++ b/debian/tests/expr.ml
@@ -0,0 +1,25 @@
+type expr =
+  | EConst of int
+  | EAdd of expr * expr
+  [@@deriving visitors { variety = "iter" }]
+
+let weight (e : expr) : int =
+  (* return the weight of an expr, where constants have weight 2, and *)
+  (* additions have weight 5.                                         *)
+  let v = object
+    val mutable weight = 0
+    method weight = weight
+    inherit [_] iter as super
+    method! visit_EAdd env e0 e1 =
+      weight <- weight + 5;
+      super#visit_EAdd env e0 e1
+    method! visit_EConst env i =
+      weight <- weight + i;
+      super#visit_EConst env i
+    end in
+  v#visit_expr () e;
+  v#weight
+;;
+
+let c = EConst 2 in
+let e = EAdd(c,EAdd(c,c)) in print_int (weight e);;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-ocaml-maint/packages/ocaml-visitors.git

_______________________________________________
Pkg-ocaml-maint-commits mailing list
Pkg-ocaml-maint-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-ocaml-maint-commits

Reply via email to