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 c5ff346549e7 (Postfix) with ESMTPS id 960D32DF5 for ; Mon, 19 Mar 2018 10:42:02 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.48,330,1517871600"; d="scan'208";a="318774935" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 19 Mar 2018 11:42:01 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id 3FA6782418; Mon, 19 Mar 2018 11:42:01 +0100 (CET) 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 EC8F2823D7 for ; Mon, 19 Mar 2018 11:41:53 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=rixed@happyleptic.org; spf=None smtp.mailfrom=rixed@happyleptic.org; spf=None smtp.helo=postmaster@pim.happyleptic.org IronPort-PHdr: =?us-ascii?q?9a23=3AIj45qBRF4CDW7kCF0LgV1HTwu9psv+yvbD5Q0YIu?= =?us-ascii?q?jvd0So/mwa6yZhGN2/xhgRfzUJnB7Loc0qyK6/umATRIyK3CmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+?= =?us-ascii?q?KPjrFY7OlcS30P2594HObwlSizexfb1/IA+qoQnNq8IbnZZsJqEtxxXTv3BGYf?= =?us-ascii?q?5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM30u683wqRbD?= =?us-ascii?q?VwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xymp4rx1QxH0li?= =?us-ascii?q?gIKz858HnWisNuiqJbvAmhrAF7z4LNfY2ZKOZycqbbcNgHR2ROQ9xRWjRPDI28?= =?us-ascii?q?cYUBEukPPehXoIbhulQBrxWxCBKwBO/z0DJEmmP60Lck3+knDArI3BYgH9ULsH?= =?us-ascii?q?nMstj6KrodUfq0zKbU0D7Oce1Z2TP56IjJbB8hu+yHULVqccrQxkggCR7Kg06Q?= =?us-ascii?q?qYP/JzOVzuQMs2yF4Op4SeKvinIopxt2oji1ycchk4/EjZ8bxFDD8CV22oc1Jd?= =?us-ascii?q?ugRU50YN6kDJtQtzyBOIdsXswiRGRotSAnwbMFoZ62ZCgHxI46yxPRa/GLaZWE?= =?us-ascii?q?7xLiWeqLPDt1h3BodKq8ihuy60Ss1+LxW8qu3FtLoCdJiNjBumwL2hfO8MaIUO?= =?us-ascii?q?F98V2k2TuX1wDc9OVEIUcsmKrDKp4hx6Q8lpoJvkTbBi/3mEH2g7GOdkU4++in?= =?us-ascii?q?9/7rYrL8pp+TL4N0iwf+PboymsGnAek0KBUCUmab9OimybHu/Uz0TK9XgvA1kK?= =?us-ascii?q?TVqJXaKt4apq69DQ9VyIEj6xOnAje80dQZkmcII09edRKHlYfpI0nOIfD8Dfih?= =?us-ascii?q?m1SsjDZryOzcMr3mGJXNIWDPkK39crZl905c1A0zwMhD6J1OD7EBJOv/WkvwtN?= =?us-ascii?q?zDEh80KBe0wubiCNVlzIwSQ2OPAqmDMKPTq1CE/OwvI/PfLLMS7Rz0K/0s4bbL?= =?us-ascii?q?imEwgFYHNf2j1JsSYXaQFP1mJkyfZDznhdJXQkkQuQ9rZ+HmklyJGRVeY3KzUr?= =?us-ascii?q?h0sis6GI+qJYfKXpi8hLGZwCawWJpMaTYVWRi3DX70etDcCL83YyWIL5oky2Rc?= =?us-ascii?q?DOnze8oazRir8TTC5f9iJ+vQ9DcfsMu8hth8//XCkRwq6T1/ScOH3DPVFj0mri?= =?us-ascii?q?YzXzYzmZtHjwll0F7ajvp4iuRABNhe/+9IWUE9L5GOl7UnWeC3YRrIe5KycHjj?= =?us-ascii?q?QtiiBmtoHMowxpkOal5lCtGvlgzC1GytGbBHz7E=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BPBQBKk69a/7uchwVdHQEBBQELAYMfM?= =?us-ascii?q?WZyKI5pjQdCAQEBAQEBBoJLlACCEgsfhHECCIM2GQYGMRcBAgEBAQEBAQEBAWo?= =?us-ascii?q?ogjgkAYJJBicTBgEBNwEPCyETEg8FSYUeEQEKnxGIbYJaOoMBAQEFhU6CBgiFM?= =?us-ascii?q?4IVgQ2FPIMeAoEyg2yCMZg5CYYHiRsPggyLIYkwhwWBKiABNYFSMxoIKAg6gkM?= =?us-ascii?q?JghqOSXOQQwEBAQ?= X-IPAS-Result: =?us-ascii?q?A0BPBQBKk69a/7uchwVdHQEBBQELAYMfMWZyKI5pjQdCAQE?= =?us-ascii?q?BAQEBBoJLlACCEgsfhHECCIM2GQYGMRcBAgEBAQEBAQEBAWoogjgkAYJJBicTB?= =?us-ascii?q?gEBNwEPCyETEg8FSYUeEQEKnxGIbYJaOoMBAQEFhU6CBgiFM4IVgQ2FPIMeAoE?= =?us-ascii?q?yg2yCMZg5CYYHiRsPggyLIYkwhwWBKiABNYFSMxoIKAg6gkMJghqOSXOQQwEBA?= =?us-ascii?q?Q?= X-IronPort-AV: E=Sophos;i="5.48,330,1517871600"; d="scan'208";a="318774910" Received: from pim.happyleptic.org ([5.135.156.187]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 19 Mar 2018 11:41:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=happyleptic.org; s=20160823; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=RTupwa1ijAmztmgZcmA9eczvxROeL8HpxsjRFnS0UyE=; b=V2okPZvxfqqWFLbzGaaOAzFSA0g0EFsbZgp9y7q/R/0JyZi2Niv6ZUcXFmQq4P47/arv949/7wcCBpIudboa7TKPjP3oy4/q2OehJOZ9+O9rbes9kIqB7YPVjtqdTHNbsK7aZw92RvJp6+npmsGCWmXZ8GYU7rwaz8HHW1lnUg8=; Received: from s55943f3c.adsl.online.nl ([85.148.63.60] helo=rxdmac.local) by pim.happyleptic.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1exsEi-0001cj-AO; Mon, 19 Mar 2018 11:41:52 +0100 Date: Mon, 19 Mar 2018 11:41:46 +0100 From: Cedric Cellier To: Bahman Movaqar Cc: caml-list@inria.fr Message-ID: <20180319104145.GB80588@rxdmac.local> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Subject: Re: [Caml-list] On variants, integers and testing Reply-To: Cedric Cellier X-Loop: caml-list@inria.fr X-Sequence: 16731 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: -[ Fri, Mar 16, 2018 at 12:12:56PM +0100, Bahman Movaqar ]---- > However, when it comes to testing, things are not that simple. Now that I > have exported only 1 function in the .mli, I can only test that 1 function. > Is this the proper way[2]? This is one of the reasons some people don't like to use mli files. Another approach is to define (and document) the signatures in ".ml" file (named for instance "yadayada_intf.ml") and then the implementation can be written and exposed fully, knowing that you can create another one and constraint it to the signature later on. Example: --- yadayada_intf.ml --- 8< --- 8< --- (** This is library yadayada *) module type S = sig (** The type of yadayadas *) type t (** Create a yadayada from a xyz: *) val create : xyz -> t (** Call this to perform a foo with your yadayada created with [create]: *) val foo : t -> wooz end --- >8 --- >8 --- Then you implement the actual thing in yadayada_impl.ml: --- yadayada_impl.ml --- 8< --- 8< --- (* Implementation for yadayada *) type t = ... let create x = ... let foo t = ... --- >8 --- >8 --- That implementation you can test from "yadayada_tests.ml" for instance, since none of it is hidden. Then, you can provide users with a simplified module Yadayada.M, defined in "yadayada.ml": --- yadayada.ml --- 8< --- 8< --- module M = Yadayada_impl : Yadayada_intf.S --- >8 --- >8 --- Plenty of variations are possible of course, but the names "t" for the main type, "S" for the main signature and "M" for the main module (or "Make" if it's a functor) are common. The drawback of this technique is that it tends to lead toward a design with plenty of modules and functors, which makes reading the code more complex (and is also harder to inline efficiently). Note that for inline tests you have the qtest (https://github.com/vincent-hugot/qtest) tool that I find quite nice for inline tests as long as you do not try to shoehorn it into the large functional test framework it is not designed to be. -- Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs