PlUnit is a unit testing library for Prolog. Its goals are:
plunit_assert
is:The API documentation is generated by PlDoc and the latest is always available here:
https://simonharris.github.io/plunit_assert/
Packages are hosted here:
https://packages.pointbeing.net/plunit_assert/
Thus, the current version of the library can be installed using:
?- pack_install(plunit_assert, [url('https://packages.pointbeing.net/plunit_assert/plunit_assert-0.2.1.tgz')]).
It is also discoverable via pack_list/1:
?- pack_list(plunit_assert). % Contacting server at https://www.swi-prolog.org/pack/query ... ok p plunit_assert@0.2.1 - An expressive xUnit-like API for PlUnit with more helpful fail messages true. ?- pack_install(plunit_assert). ...etc...
?- assert_type(3.0, boolean). [plunit_assert] Asserted 3.0 is of type 'boolean' but got 'float' false.
?- assert_equals(3+1, 4). true. ?- assert_is(3+1, 4). [plunit_assert] Asserted identity but 3+1 and 4 are not identical false.
?- assert_lte(3^7, 6+9.6). [plunit_assert] Comparison failed: 3^7 (2187) is not less than or equal to 6+9.6 (15.6) false.
plunit_assert.pl -- The test API for plunit_assert | ||
---|---|---|
assert_equals/2 | This is a superset of assert_is/2 and arithmetic comparison with =:=. | |
assert_false/1 | Test that Goal fails and therefore is falsy. | |
assert_gt/2 | Test that A is greater than B. | |
assert_gte/2 | Test that A is greater than or equal to B. | |
assert_in/2 | Test that Var is in Collection. | |
assert_is/2 | Test that A and B are identical terms. | |
assert_is_not/2 | Test that A and B are not identical terms. | |
assert_lt/2 | Test that A is less than B. | |
assert_lte/2 | Test that A is less than or equal to B. | |
assert_not_equals/2 | Test that A and B are not equal terms. | |
assert_not_in/2 | Test that Var is not in Collection. | |
assert_not_type/2 | Test that Var is not of type Type. | |
assert_not_unbound/1 | Test that Var is not unbound. | |
assert_output/3 | Test that a predicate's output arguments match what is expected. | |
assert_test_fails/1 | Meta test to check that Goal would trigger a PlUnit test fail. | |
assert_test_message/2 | Meta test to check we get roughly the right fail messages back. | |
assert_test_passes/1 | Meta test to check that Goal would not trigger a PlUnit test fail. | |
assert_true/1 | Test that Goal succeeds and therefore is truthy. | |
assert_type/2 | Test that Var is of type Type. | |
assert_unbound/1 | Test that Var is unbound. |