caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Veber <philippe.veber@gmail.com>
To: "forum@x9c.fr" <forum@x9c.fr>
Cc: Marek Kubica <marek@xivilization.net>, caml-list@inria.fr
Subject: Re: [Caml-list] Preferred layout for new packages
Date: Thu, 15 Nov 2012 10:00:41 +0100	[thread overview]
Message-ID: <CAOOOohTRa6dGSQQsc3=Nf8bZ3jPUF6KKTVR68SZeAF3ka+XZrg@mail.gmail.com> (raw)
In-Reply-To: <6973F6F3-317F-46A6-A53D-8796FB33E679@x9c.fr>

[-- Attachment #1: Type: text/plain, Size: 3175 bytes --]

 I think it's critical here to distinguish two purposes:
1. providing (compiler-checked) examples of a function for documentation
2. writing tests to check a module's functions seriously.

Putting test code in comments is a very nice way to achieve (1), but a
terrible way to achieve (2). In a documentation you want to illustrate the
use of your function, but writing a test for the function is not the most
direct, hence the most intelligible way to do so. Writing a test and an
example are two different things and you may confuse a user when putting
the former instead of the latter in your documentation. So I'd say code
extraction from documentation is very nice, only if it serves the purpose
of the documentation (of course the extraction enables to check the
examples, which is a nice feature).

Your mlt proposal seems to me a very nice way to organize test code (in the
second sense), as it emphasizes through the file extensions the following
holy trinity: specification, implementation and tests. Up to now, I would
write a separate directory with tests (written with oUnit), but now with
your suggestion in mind, it really feels wrong to do things that way.

Maybe the only limitation of your approach is that the test modules have to
respect the dependencies between the library modules: if A uses B then your
tests in B cannot use values in A. But I don't think it matters much, as
we're talking about unit test here.

Thanks for this proposal, I will definitely give it a try!

ph.




2012/11/14 forum@x9c.fr <forum@x9c.fr>

>
> Le 14 nov. 2012 à 18:00, Marek Kubica a écrit :
>
> > On Wed, 14 Nov 2012 09:42:09 -0500
> > Edgar Friendly <thelema314@gmail.com> wrote:
> >
> >> (…)
> >
> > I actually like test extraction frameworks, tools like nose and py.test
> > have made writing tests with Python much nicer, that's why I'm somehow
> > unimpressed how verbose OUnit is. But having the test code in a comment
> > seems ugly to me. Maybe there could be some CamlP4 hack to exclude it
> > on normal compilation?
>
> Being not found of extraction myself, I made another proposal in the
> latest revision of Kaputt: instead of using mli/ml file couples, I tend to
> now use mli/ml/mlt file triples. In this setting, the mlt file simply
> contains
> the code related to tests. Then, at compilation a small camlp4 preprocessor
> concatenates the contents of ml and mlt files before actual compilation.
>
> My understanding is that it reconciles two antagonistic goals:
>   - separate application code from test code;
>   - allow test code to access unexported elements.
>
> I would be glad to hear what people think of this scheme, independently
> of the Kaputt library itself (which I am not advertising here). One can
> read
> more in section 3.3 of the manual available at:
>     http://kaputt.x9c.fr/downloads.html
>
>
> Regards,
>
> Xavier Clerc
>
> --
> 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
>

[-- Attachment #2: Type: text/html, Size: 4032 bytes --]

  reply	other threads:[~2012-11-15  9:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-14 11:43 Marek Kubica
2012-11-14 14:41 ` Török Edwin
2012-11-14 16:36   ` Marek Kubica
2012-11-15  1:20   ` Francois Berenger
2012-11-14 14:42 ` Edgar Friendly
2012-11-14 17:00   ` Marek Kubica
2012-11-14 18:00     ` forum
2012-11-15  9:00       ` Philippe Veber [this message]
2012-11-14 18:17     ` Martin Jambon
2012-11-14 18:48       ` Markus Mottl
2012-11-14 19:35         ` Martin Jambon
2012-11-15  6:36     ` Cedric Cellier
2012-11-15  7:24       ` Marek Kubica
2012-11-15  9:17         ` rixed
     [not found] <fa.38rAsBvHd+quECbtcbTH9HW+J6U@ifi.uio.no>
     [not found] ` <fa.YCrkHurCi6yY5s0Qg1r6uLWNQdY@ifi.uio.no>
     [not found]   ` <fa.oeqp0ymFFL+o76ut/LjBeQhUcjQ@ifi.uio.no>
     [not found]     ` <fa.pEDV80ILnW8x1YQyKuF3NBsK3Kw@ifi.uio.no>
     [not found]       ` <fa.LQofvqHUt8xj1kM1rvmQZF+Z7rw@ifi.uio.no>
2012-11-15  8:13         ` vincent.hugot
2012-11-15  8:31           ` Francois Berenger
2012-11-15  9:20           ` rixed
2012-11-15 17:22             ` Aleksey Nogin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOOOohTRa6dGSQQsc3=Nf8bZ3jPUF6KKTVR68SZeAF3ka+XZrg@mail.gmail.com' \
    --to=philippe.veber@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=forum@x9c.fr \
    --cc=marek@xivilization.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).