From 5cb0ed73f360a5827fafa72a555ca80447d6de9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20Courant?= Date: Mon, 7 Dec 2020 13:29:28 +0100 Subject: [PATCH] Add tests for argument of functor --- miniml/compiler/hello.ml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/miniml/compiler/hello.ml b/miniml/compiler/hello.ml index 9797090..da2a9b4 100644 --- a/miniml/compiler/hello.ml +++ b/miniml/compiler/hello.ml @@ -272,15 +272,18 @@ let () = run_and_print_exn (fun () -> div 1 0) let () = print "\nFunctors:\n" -module X(A : sig val x : int end) = struct - let x = 2 * A.x +module F(X : sig val x : int end) = struct + let x = 2 * X.x end -module Y = X(struct let x = 21 end) -module Z = X(struct let x = 12 end) +module A = F(struct let x = 21 end) +module B = F(struct let x = 12 end) +module X = struct let () = print " only once" let x = 16 end +module C = F(X) +module D = F(X) let () = - print_int Y.x; print_int Z.x + print_int A.x; print_int B.x; if C.x = D.x then print " ok" else print " ko"