Unit testing environment for SWI-Prolog and SICStus Prolog. For usage, please visit http://www.swi-prolog.org/pldoc/package/plunit.
- current_test_flag(?Name, ?Value) is nondet[private]
- Query flags that control the testing process. Emulates SWI-Prologs flags.
- set_test_flag(+Name, +Value) is det[private]
- Specifies how to deal with test suites. Defined options are:
- Whether or not the tests must be loaded. Values are
normal(only if not optimised)
- When the tests are run. Values are
false), report successful tests using message level
silent, only printing errors and warnings.
- How to test whether code is subject to occurs check
false(default), STO is not considered. If
trueand supported by the hosting Prolog, code is run in all supported unification mode and reported if the results are inconsistent.
true(default =false), cleanup report at the end of run_tests/1. Used to improve cooperation with memory debuggers such as dmalloc.
- True if tests must be loaded.
- begin_tests(+UnitName:atom) is det
- begin_tests(+UnitName:atom, Options) is det
- Start a test-unit. UnitName is the name of the test set. the
unit is ended by :-
- end_tests(+Name) is det
- Close a unit-test module.
- make_unit_module(+Name, -ModuleName) is det[private]
- unit_module(+Name, -ModuleName) is det[private]
- expand_test(+Name, +Options, +Body, -Clause) is det[private]
test(Name, Options):- Body into a clause for 'unit test'/4 and 'unit body'/2.
- expand(+Term, -Clauses) is semidet[private]
- valid_options(+Options, :Pred) is det[private]
- Verify Options to be a list of valid options according to Pred.
- test_option(+Option) is semidet[private]
- True if Option is a valid option for
- test_option(+Option) is semidet[private]
- True if Option is a valid option for :-
- run_tests is semidet
- run_tests(+TestSet) is semidet
- Run tests and report about the results. The predicate run_tests/0 runs all known tests that are not blocked. The predicate run_tests/1 takes a specification of tests to run. This is either a single specification or a list of specifications. Each single specification is either the name of a test-unit or a term <test-unit>:<test>, denoting a single test within a unit.
- run_tests_in_files(+Files:list) is det[private]
- Run all test-units that appear in the given Files.
- Called indirectly from make/0 after Files have been reloaded.
- run_test(+Unit, +Name, +Line, +Options, +Body) is det[private]
- Run a single test.
- test_caps(-Type, +Unit, +Name, +Line, +Options, +Body, -Result, -Key) is nondet[private]
- run_test_6(+Unit, +Name, +Line, +Options, :Body, -Result) is det[private]
- Result is one of:
blocked(Unit, Name, Line, Reason)
failure(Unit, Name, Line, How)
success(Unit, Name, Line, Determinism, Time)
setup_failed(Unit, Name, Line)
- non_det_test(+Expected, +Unit, +Name, +Line, +Options, +Body, -Result)[private]
- Run tests on non-deterministic predicates.
- result_vars(+Expected, -Vars) is det[private]
- Create a term
v(V1, ...)containing all variables at the left side of the comparison operator on Expected.
- nondet_compare(+Expected, +Bindings, +Unit, +Name, +Line) is semidet[private]
- Compare list/set results for non-deterministic predicates.
- cmp(+CmpTerm, -Left, -Op, -Right) is det[private]
- call_det(:Goal, -Det) is nondet[private]
- True if Goal succeeded. Det is unified to
trueif Goal left no choicepoints and
- match_error(+Expected, +Received) is semidet[private]
- True if the Received errors matches the expected error. Matching is based on subsumes_term/2.
- setup(+Module, +Context, +Options) is semidet[private]
- Call the setup handler and fail if it cannot run for some
reason. The condition handler is similar, but failing is not
considered an error. Context is one of
- If it is the setup handler for a unit
- test(Unit, Name, Line)
- If it is the setup handler for a test
- call_ex(+Module, +Goal)[private]
- Call Goal in Module after applying goal expansion.
- cleanup(+Module, +Options) is det[private]
- Call the cleanup handler and succeed. Failure or error of the cleanup handler is reported, but tests continue normally.
- assert_cyclic(+Term) is det[private]
- Assert a possibly cyclic unit clause. Current SWI-Prolog assert/1 does not handle cyclic terms, so we emulate this using the recorded database.
- begin_test(Unit, Test, Line, STO) is det[private]
- end_test(Unit, Test, Line, STO) is det[private]
- Maintain running/5 and report a test has started/is ended using
plunit(begin(Unit:Test, File:Line, STO))
plunit(end(Unit:Test, File:Line, STO))
- running_tests is det
- Print the currently running test.
- check_for_test_errors is semidet[private]
- True if there are no errors, otherwise false.
- report is det[private]
- Print a summary of the tests that ran.
- test_report(What) is det
- Produce reports on test results after the run.
- current_test_set(?Unit) is nondet[private]
- True if Unit is a currently loaded test-set.
- unit_file(+Unit, -File) is det[private]
- unit_file(-Unit, +File) is nondet[private]
- load_test_files(+Options) is det
- Load .plt test-files related to loaded source-files.
print_message(Level, Term), where Level is one of
- user:message_hook(+Severity, +Message, +Lines) is semidet[multifile]
- Redefine printing some messages. It appears SICStus has no way to get multiple messages at the same line, so we roll our own. As there is a lot pre-wired and checked in the SICStus message handling we cannot reuse the lines. Unless I miss something ...
The following predicates are exported, but not or incorrectly documented.