caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] ANN: should.ml, literate assertions for OCaml
@ 2013-08-26 18:34 Mike Lin
  2013-08-27  8:21 ` Romain Bardou
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Lin @ 2013-08-26 18:34 UTC (permalink / raw)
  To: caml-list

[-- 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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] ANN: should.ml, literate assertions for OCaml
  2013-08-26 18:34 [Caml-list] ANN: should.ml, literate assertions for OCaml Mike Lin
@ 2013-08-27  8:21 ` Romain Bardou
  2013-08-27  9:43   ` Oliver Bandel
  0 siblings, 1 reply; 3+ messages in thread
From: Romain Bardou @ 2013-08-27  8:21 UTC (permalink / raw)
  To: caml-list

I'm not sure a language resembling plain English is a good idea (for
instance, does "above" mean ">" or ">="?) but I like the tricks you used
to avoid the need for a preprocessor :)

Cheers,

-- 
Romain Bardou

Le 26/08/2013 20:34, Mike Lin a écrit :
> 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
> |
> 
> |
> |


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] ANN: should.ml, literate assertions for OCaml
  2013-08-27  8:21 ` Romain Bardou
@ 2013-08-27  9:43   ` Oliver Bandel
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Bandel @ 2013-08-27  9:43 UTC (permalink / raw)
  To: Romain Bardou; +Cc: caml-list

I think, the example looks very nice. :-)

Above IMHO would be ">"
">=" might be # equal # or # above... if the language allows it...
Or, when looking at the example, there is at-most...
...if english language allows, possibly at-least would be ok.
(But mothertongue english speakers might disagree.)

Ciao,
   Oliver


Am 27.08.2013 um 10:21 schrieb Romain Bardou <romain.bardou@inria.fr>:

> I'm not sure a language resembling plain English is a good idea (for
> instance, does "above" mean ">" or ">="?) but I like the tricks you used
> to avoid the need for a preprocessor :)
> 
> Cheers,
> 
> -- 
> Romain Bardou
> 
> Le 26/08/2013 20:34, Mike Lin a écrit :
>> 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
>> |
>> 
>> |
>> |
> 
> 
> -- 
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-27  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-26 18:34 [Caml-list] ANN: should.ml, literate assertions for OCaml Mike Lin
2013-08-27  8:21 ` Romain Bardou
2013-08-27  9:43   ` Oliver Bandel

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).