From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id F23657FACD for ; Mon, 29 Sep 2014 12:48:20 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.130; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.130; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.kundenserver.de) identity=helo; client-ip=212.227.126.130; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@mout.kundenserver.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At8BAHA4KVTU436ClGdsb2JhbABgDoMVPspqh1ICgQsWAREBAQEBBwsLCRIuhAQBAQRVJBALDjhXBhMJiDkJqhMhbw2UIQEXig6FaiYHhEsFhiiLeJJVBZEuQmoBgkkBAQE X-IPAS-Result: At8BAHA4KVTU436ClGdsb2JhbABgDoMVPspqh1ICgQsWAREBAQEBBwsLCRIuhAQBAQRVJBALDjhXBhMJiDkJqhMhbw2UIQEXig6FaiYHhEsFhiiLeJJVBZEuQmoBgkkBAQE X-IronPort-AV: E=Sophos;i="5.04,619,1406584800"; d="asc'?scan'208";a="98398325" Received: from mout.kundenserver.de ([212.227.126.130]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Sep 2014 12:48:20 +0200 Received: from office1.lan.sumadev.de (dslb-178-004-068-137.178.004.pools.vodafone-ip.de [178.4.68.137]) by mrelayeu.kundenserver.de (node=mreue007) with ESMTP (Nemesis) id 0MPeNx-1XcfEP0ukD-004nBO; Mon, 29 Sep 2014 12:48:16 +0200 Received: from [192.168.10.100] (unknown [5.146.48.81]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 5431FDC270; Mon, 29 Sep 2014 12:48:15 +0200 (CEST) Message-ID: <1411987686.5797.128.camel@e130> From: Gerd Stolpmann To: Eric Cooper Cc: caml-list@inria.fr Date: Mon, 29 Sep 2014 12:48:06 +0200 In-Reply-To: <20140928230638.GT2829@cooper-siegel.org> References: <20140928230638.GT2829@cooper-siegel.org> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-uwneY/dvC2OpP8tVPicz" X-Mailer: Evolution 3.10.4-0ubuntu1 Mime-Version: 1.0 X-Provags-ID: V02:K0:N3uS4vluE3tKFuBxHXaHqeJv9hn8zf3HkrTbNthpwHi srgtXQwfNJq2dAtI0dDYGADk7t+MM4J7hwQupVs0cX/F6SVCuy YD1CfeNzw9Js3U2oCpEU3kBUYcnY50dtQ9VJhfA3/0TSFrbCSb SU7naZ+fTcAyF+7hoNjHwEFA9/WcjohkWSKULR0mrLbxb4Az85 cvh1+UrjlKMU/syUZbTdrGqWL7Be/rgYPYQ3bH1elEQyESpOXe QzbNmGpOyfzYamCT1K5W/Z5gSOBpgnEdW5w4g+qD/3AmIcKggr kfs40hPQUhuvD3LEVjRsDJKupCyzEbfrorZCrQkxRDoPJpaOYA mz5cDgqpheSEO+l8v0DklS8Lk6z4HHxDrgf8cOFRe X-UI-Out-Filterresults: notjunk:1; Subject: Re: [Caml-list] testing private functions with oUnit --=-uwneY/dvC2OpP8tVPicz Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable I think there is some missing functionality in OCaml: a mechanism to grant access to something that is normally hidden. This is not only important for unit testing but for debugging in general (remember that even ocamldebug cannot break module abstractions). What about this idea: modules (and only modules) can have associated visibility attributes. These are set with the definition or in the signature, e.g. module Implementation { "debug" } =3D struct ... end and are part of the cmi file. This imposes a restriction on the module path - Implementation may then only occur as part of a module path if it is explicitly allowed (e.g. that could be a command-line switch, and the debugger would allow everything). When using this technique, you'd normally put everything into an Implementation sub-module that is access-protected, and you'd redefine what is part of the regular interface: module Implementation { "debug" } =3D struct ... end import Implementation (* or redefine definition by definition:=20 let my_function =3D Implementation.my_function *) And in the mli (which may now even be superfluous unless you want to document the API): val my_function : ... module Implementation { "debug" } : sig ... end If there was a special ANY module type that unifies with anything: module Implementation { "debug" } : ANY This would then simply export all definitions. There could be additional utilities for stripping definitions with access control tokens from the cmi files. The whole point is to grant the developer of a certain library more rights than the user of a library. Gerd Am Sonntag, den 28.09.2014, 19:06 -0400 schrieb Eric Cooper: > I'd like to write unit tests for functions not exported in a .mli > file. The only way I can see is to remove the .mli file while > building the test, so the whole .ml file is visible. Is there a better > way, preferably integrated with ocamlmake + findlib? >=20 > --=20 > Eric Cooper e c c @ c m u . e d u >=20 --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------ --=-uwneY/dvC2OpP8tVPicz Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJUKTjmAAoJEAaM4b9ZLB5T+FIH/iLIXkDsBj5cOqLu4BvihdMq RIlETO+7OexqwKoirwfH3G9a9XooFyn2mT/s0crlVml0oH5/Glf/AeJdFXkymzrA bzyQ12h8hURWmZKHNuEG7rDxNDveaXJ/f77z0JC6Bl1iZtx8badr/vqADAESnFv0 ib0uu6grr5RKF/PLCVEroVnEY7JIF76ZYZyIvpJE1gBR8pFTDeW3mlJwYRRoWC/r 1iznu+dmEhb6gec5WBnlqkEhrChAlvqCGUR8gvLPDHga4FSwLBWjFisuvnDd344Q l1Fo8NU9/CBGecQEh29I8REXApnqEkVgSxbl7mW28ujp+yR8q2T3V6p1NN8L8Ig= =fmDe -----END PGP SIGNATURE----- --=-uwneY/dvC2OpP8tVPicz--