[m-users.] Basic Unit Test Framework
Charles Shuller
charles.shuller at gmail.com
Mon Jul 13 06:21:28 AEST 2015
>
> Can I use your unit test framework to test predicates with an arbitrary
> number of arguments and modes?
>
Test cases CAN test a predicate of an arbitrary number of arguments, but I
suspect the correct answer is no ;)
Test cases are defined as a deterministic predicate with a single out
parameter for the result. You then implement the call to your code under
test within the test case. A simple test case below, implemented in terms
of a lambda:
test_case("AreEqualPass", (pred(Disposition::out) is det :-
assertions.are_equal(univ(1), univ(1), Disposition)))
> In my own little unit test module (attached), I use different test
> predicates for this purpose because I didn’t find another solution yet.
>
> E.g.
>
> 1. testPred/7 to to test a predicate that takes two input parameters and
> either succeeds or fails.
>
> 2. testPredio/6 to test a predicate that takes one input parameter and
> returns one output parameter.
>
> 3. testPrediio/7 to test a predicate that takes two input parameters and
> returns one output parameter.
>
> 4. testDCG/6 to test a DCG parser predicate that returns a parsing result
>
>
I did consider this approach, but decided when it came time to associate
arguments with a test case, I'd handle it with a closure or bind them to
the test case as a list(univ). I have no idea which approach is better
though.
> Best regards,
>
> Dirk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20150712/c6e3bde4/attachment.html>
More information about the users
mailing list