caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Mike Lin <mlin@mlin.net>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: [Caml-list] ANN: should.ml, literate assertions for OCaml
Date: Mon, 26 Aug 2013 11:34:24 -0700	[thread overview]
Message-ID: <CADxsieaPOzyw1vYAe7COt_gKREvqthgvd8y56tzWSwqDA30EpA@mail.gmail.com> (raw)

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

Should.ml is a little library for writing assertion statements in a
domain-specific language roughly resembling plain English. This makes
lengthy series of assertions (such as in unit tests) a little nicer to read
- example pasted below. Through some mild abuse of objects and operators, I
avoided the need for any preprocessor or syntax extension.

https://github.com/mlin/should.ml
opam update && opam install should

Happy testing!
Mike

Example:

open Should

let int_test_case () =
    let x = 123 in begin
        x $hould # equal 123;
        x $hould # not # equal 0;

        x $hould # be # above 122;
        x $hould # be # at # most 124;

        x $hould # be # within (122,123);
        x $houldn't # be # within (1,3)
    end

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

             reply	other threads:[~2013-08-26 18:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-26 18:34 Mike Lin [this message]
2013-08-27  8:21 ` Romain Bardou
2013-08-27  9:43   ` Oliver Bandel

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=CADxsieaPOzyw1vYAe7COt_gKREvqthgvd8y56tzWSwqDA30EpA@mail.gmail.com \
    --to=mlin@mlin.net \
    --cc=caml-list@inria.fr \
    /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).