public final class ProjogTestParser extends Object
ProjogTestContent objects.
System test files contain both standard Prolog syntax plus extra detail contained in comments which specify queries and their expected results. The system tests have two purposes:
Examples of how system tests can be specified using comments (i.e. lines prefixed with a %) are:
?- test. succeeds once and no attempt will be made to find an alternative
solution: %TRUE test
?- test. succeeds once and will fail when an attempt is made to find an
alternative solution: %TRUE_NO test
?- test. will fail on the first attempt to evaluate it: %FAIL test
?- test. will succeed three times and there will be no attempt to evaluate
it for a fourth time: %?- test %YES %YES %YES
?- test. will succeed three times and will fail when an attempt is made to
evaluate it for a fourth time: %?- test %YES %YES %YES %NO
?- repeat. will succeed three times. The %QUIT markup indicates
that after the third attempt then stop testing for alternative solutions, even though they may exist. %?- repeat %YES %YES %YES %QUIT
?- test(X). will succeed three times and there will be no attempt to
evaluate it for a fourth time, specifying expectations about variable unification: %?- test(X) % X=a % X=b % X=cThe test contains the following expectations about variable unification:
X will be instantiated to a.X will be instantiated to b.X will be instantiated to c.?- test(X,Y). will succeed three times and will fail when an attempt is
made to evaluate it for a fourth time, specifying expectations about variable unification: %?- test(X,Y) % X=a % Y=1 % X=b % Y=2 % X=c % Y=3 %NOThe test contains the following expectations about variable unification:
X will be instantiated to a and the variable
Y will be instantiated to 1.X will be instantiated to b and the variable
Y will be instantiated to 2.X will be instantiated to c and the variable
Y will be instantiated to 3.?- repeat(3), write('hello world'), nl. will succeed three times and there
will be no attempt to evaluate it for a fourth time, specifying expectations about what should be written to standard
output:
%?- repeat(3), write('hello world'), nl
%OUTPUT
% hello world
%
%OUTPUT
%YES
%OUTPUT
% hello world
%
%OUTPUT
%YES
%OUTPUT
% hello world
%
%OUTPUT
%YES
The test contains expectations that every evaluation will cause the text hello world and a
new-line character to be written to the standard output stream.?- repeat(X). an exception will be thrown with a particular
message: %?- repeat(X) %ERROR Expected Numeric but got: NAMED_VARIABLE with value: X
test.html: %LINK test

| Constructor and Description |
|---|
ProjogTestParser(File testScript) |
| Modifier and Type | Method and Description |
|---|---|
ProjogTestContent |
getNext() |
static List<ProjogTestQuery> |
getQueries(File testScript) |
public ProjogTestParser(File testScript) throws IOException
IOExceptionpublic static List<ProjogTestQuery> getQueries(File testScript)
RuntimeException - if script has no tests and no linkspublic ProjogTestContent getNext()
Copyright © 2022. All rights reserved.