Brachylog icon indicating copy to clipboard operation
Brachylog copied to clipboard

Please add test cases to the distribution

Open triska opened this issue 8 years ago • 4 comments

Please add a set of test cases to the distribution, so that it is easier to verify changes in the compiler.

The PlUnit framework may come in handy for this. With run_tests/0, one can simply run all test cases and gets a report of what has worked.

triska avatar Jun 12 '16 08:06 triska

@triska I just commited unit test for brachylog_reverse. I'm not sure if I'm doing this right so I'll stop for now. They are testing in a non-deterministic way with findall/3 because almost all brachylog_predicates have branch points from the different type cases that are usually not useful. However I don't want to remove them because a) it would take a lot of effort and b) they can be useful when backtracking if we are interested in answers with possibly different types

JCumin avatar Jun 12 '16 10:06 JCumin

For inspiration, here is an example of unit tests, written by Ulrich Neumerkel: test_clpfd_tier2.pl

Note that they are using the PlUnit testing framework of SWI-Prolog. To run them, use:

?- run_tests.

PlUnit is quite flexible and also lets you state properties about all solutions. It's completely OK to have redundant choice points, but it is not OK to either omit valid solutions, or report invalid solutions. Using PlUnit is more convenient than rolling your own logic to test such properties.

triska avatar Jun 29 '16 23:06 triska

I'm finally starting on this, months after this was requested... It's lacking a lot of predicates/metapredicates right now but here's the current existing unit tests.

JCumin avatar Mar 01 '17 17:03 JCumin

Awesome work, thank you for working on this!

triska avatar Mar 01 '17 18:03 triska