-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathtests-sample.lgt
72 lines (58 loc) · 2.66 KB
/
tests-sample.lgt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Sample tester file
% Last updated on May 21, 2017
%
% This file is part of Logtalk <https://logtalk.org/>
% SPDX-FileCopyrightText: 1998-2025 Paulo Moura <[email protected]>
% SPDX-License-Identifier: Apache-2.0
%
% Licensed under the Apache License, Version 2.0 (the "License");
% you may not use this file except in compliance with the License.
% You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is a sample test suite file to help you get started. Test suite files
% are Logtalk source files defining a set of tests. The tests are usually
% run with the help of a loader file, usually named "tester.logtalk" or
% "tester.lgt", that loads the unit testing framework, the code to be tested,
% and the test suite file. See the "tester-sample.lgt" file for details.
% The unit testing framework can be found in the "tools/lgtunit" directory.
% For an overview of its features, see the "tools/lgtunit/NOTES.md" file.
% For API details, open the "docs/index.html" file in your web browser.
% See also the "testing" example, which illustrates the tests dialects
% supported by default by the "lgtunit" tool
% test suite objects are defined as prototypes extending the "lgtunit" object
% which implements the unit test framework; parametric objects can be used
% in order to define parametrizable tests
:- object(tests,
extends(lgtunit)).
% if you want to collect code coverage information, add one clause
% for the cover/1 predicate for which entity that should be covered
% and compile the code that is being tested in debug mode
cover(my_object).
cover(my_other_object).
...
% several test dialects are supported with the most simple one being
% test/1; its argument is the test name, which must be unique in a
% test suite object; the test goal must succeed for the test to be
% successful
test(my_app_1) :-
% goal that must succeed for the test to pass
some_goal.
test(my_app_2) :-
% another test goal
another_goal.
...
% the "lgtunit" tool supports other, more expressive, test dialects
% allowing e.g. testing for expected errors, determinism, defining
% setup and cleanup goals, etc; see its documentation for details
:- end_object.