This document contains acceptance tests gained in the form of bug reports.
The following test exercises the unification between numbers, in particular between real and interger numbers.
alice.tuprolog.SimpleGoalFixture | |
goal | success() |
0.0 = 0. | false |
0.9 = 0. | false |
0 = 0.9. | false |
The following test exercises the comparison between numbers, in particular between real and interger numbers.
alice.tuprolog.SimpleGoalFixture | |
goal | success() |
1.0 == 1. | false |
1 == 1.0. | false |
The following test exercises predicates for operator management.
alice.tuprolog.SimpleGoalFixture | |
goal | success() |
current_op(_, _, '+'). | true |
First of all, let's start an appropriate fixture containing an engine.
fit.ActionFixture | |
start | alice.tuprolog.EngineFixture |
Then, ask the engine to solve a query, and check variable bindings.
fit.ActionFixture | ||
enter | query | op(10, yfx, ['@', ':']), current_op(10, yfx, Op). |
check | hasSolution | true |
enter | variable | Op |
check | binding | ':' |
check | hasAnotherSolution | true |
enter | variable | Op |
check | binding | '@' |
The following test exercises the expansion of subgoals in flat lists.
First of all, let's start an appropriate fixture containing an engine.
fit.ActionFixture | |
start | alice.tuprolog.EngineFixture |
Then, ask the engine to solve a query, and check variable bindings.
fit.ActionFixture | ||
enter | theory | a. p((a,fail)). p((a)). |
enter | query | p(X), X. |
check | hasSolution | true |
enter | variable | X |
check | binding | a |
The following test exercises the identification of functors (and their subsequent evaluation) in subgoals.
First of all, let's start an appropriate fixture containing an engine.
fit.ActionFixture | |
start | alice.tuprolog.EngineFixture |
Then, ask the engine to solve a query, and check variable bindings.
fit.ActionFixture | ||
enter | query | X is 5, Y =.. ['+', X, 2], K is Y. |
check | hasSolution | true |
enter | variable | X |
check | binding | 5 |
enter | variable | Y |
check | binding | '+'(5, 2) |
enter | variable | K |
check | binding | 7 |
enter | query | X is 5, Y =.. ['+', X, 2], 10 > Y. |
check | hasSolution | true |
enter | variable | X |
check | binding | 5 |
enter | variable | Y |
check | binding | '+'(5, 2) |
The following test exercises the assertion/retraction of clauses in the knowledge base.
You cannot retract clauses belonging to a library's theory.
alice.tuprolog.SimpleGoalFixture | |
goal | success() |
retract(call(X)). | false |
Let's start an appropriate fixture containing an engine.
fit.ActionFixture | |
start | alice.tuprolog.EngineFixture |
Assertions using variables should use appropriate bindings.
fit.ActionFixture | ||
enter | theory |
ops(s). ops(y). ops(z). |
enter | query | ops(A), assert(ops_result(A)). |
check | hasSolution | true |
check | hasAnotherSolution | true |
check | hasAnotherSolution | true |
enter | query | ops_result(X). |
check | hasSolution | true |
enter | variable | X |
check | binding | s |
check | hasAnotherSolution | true |
enter | variable | X |
check | binding | y |
check | hasAnotherSolution | true |
enter | variable | X |
check | binding | z |
Retraction of clauses with a specific head must work for facts and rules.
fit.ActionFixture | ||
enter | theory |
p(0) :- !. p(1). |
enter | query | retractall(p(X)). |
check | hasSolution | true |
enter | query | p(X). |
check | hasSolution | false |
The following test exercises arithmetic operations on long numbers and on boundaries between int and long.
First of all, let's start an appropriate fixture containing an engine.
fit.ActionFixture | |
start | alice.tuprolog.EvaluationFixture |
Then, ask the engine to solve a query, and check variable bindings.
alice.tuprolog.PrologActionFixture | ||
enter | evaluable | 1169658768269 - 531550800000. |
check | value | 638107968269 |
enter | evaluable | -2147475543 - 9000. |
check | value | -2147484543 |
enter | evaluable | 1169658768269 + 531550800000. |
check | value | 1701209568269 |
enter | evaluable | 2147483543 + 8000. |
check | value | 2147491543 |
enter | evaluable | 1474845 * 3634. |
check | value | 5359586730 |
enter | evaluable | 4651880372 / -1. |
check | value | -4651880372 |
enter | evaluable | 4651880372 // -1. |
check | value | -4651880372 |
The following test exercise a cut operation to verify its proper functioning.
First of all, let's start an appropriate fixture containing an engine.
fit.ActionFixture | |
start | alice.tuprolog.EngineFixture |
Then, ask the engine to solve a query, and check variable bindings.
alice.tuprolog.PrologActionFixture | |||
enter | query | write(1), X = ','(write(a), write(b)), X, write(2), write(3). | Well, this test really hasn't anything to do with cut... |
check | hasSolutionWithOutput | true | |
check | output | 1ab23 | |
enter | theory |
b :- write(b1). b :- write(b2). b :- write(b3). |
Well, also this test really hasn't anything to do with cut... |
enter | query | X = ','(write(b0), b), X, write(after), fail. | |
check | hasSolutionWithOutput | false | |
check | output | b0b1afterb2afterb3after | |
enter | theory |
p :- a, (a -> write(a) ; write(b)), fail. a. a. |
Here we are really testing the local cut in ->/2... |
enter | query | p. | |
check | hasSolutionWithOutput | false | |
check | output | aa | |
enter | theory |
a :- ';'((b, c, ';'((write(cut), !, fail), true)), fail). a :- write(a). b :- write(b1). b :- write(b2). c :- write(c1). c :- write(c2). |
|
enter | query | a. | |
check | hasSolutionWithOutput | false | |
check | output | b1c1cut | |
enter | theory |
go :- fail. go :- write(1), X = ','(write(cut), !), X, write(2), fail. go :- write(3). |
The X meta-call should shield go/0 from the cut's effect. |
enter | query | go. | |
check | hasSolutionWithOutput | true | |
check | output | 1cut23 | |
enter | theory |
go :- fail. go :- write(1), X = ','(write(cut), !), call(X), write(2), fail. go :- write(3). |
The call/1 meta-call should shield go/0 from the cut's effect. |
enter | query | go. | |
check | hasSolutionWithOutput | true | |
check | output | 1cut23 | |
enter | theory |
x :- ';'((y, z), fail). x :- write(x). y :- write(y1). y :- write(y2). z :- ';'((write(cut), !, fail), true). z :- write(z). |
|
enter | query | x. | |
check | hasSolutionWithOutput | true | |
check | output | y1cuty2cutx | |
enter | theory |
ops :- fail. ops :- !,fail. ops :- true. |
|
enter | query | ops. | |
check | hasSolution | false |
More tests on the interaction between ;/2, ->/2, and cut, by Nathan Finley (see SourceForge bug #1675798).
alice.tuprolog.PrologActionFixture | |||
enter | theory |
a(a). a(b). a(c). go :- print(ingo), nl, a(X), (print(X), nl -> fail ; print(ingoalt), nl), fail ; print(altouter), nl, fail. go :- print(ingo2),nl. |
|
enter | query | go. | |
check | hasSolutionWithOutput | true | |
check | output | ingo a b c altouter ingo2 |
|
enter | theory |
a(a). a(b). a(c). goa :- print(ingoX), nl, a(X), print(X), print('X'), nl, !, fail ; print(ingoaltX),nl, fail. goa :- print(ingo2X),nl. goa :- print(ingo3X),nl. |
|
enter | query | goa. | |
check | hasSolutionWithOutput | false | |
check | output | ingoX aX |
|
enter | theory |
gob :- print(ingoX), nl, (print(Y), print('X'), nl, !, fail ; print(ingoaltX), nl), fail. gob :- print(ingo2X),nl. |
|
enter | query | gob. | |
check | hasSolutionWithOutput | false | |
check | output | ingoX Y_e1X |
|
enter | theory |
a(a). a(b). a(c). b(bbb). goc :- print(aaa), nl, a(X), (print(hasAA_), print(X), nl -> b(B), print(hasBB_), print(B), nl, fail ; print(altern)) ; print(alternate), nl, fail. goc :- print(a222), nl. |
|
enter | query | goc. | |
check | hasSolutionWithOutput | true | |
check | output | aaa hasAA_a hasBB_bbb hasAA_b hasBB_bbb hasAA_c hasBB_bbb alternate a222 |
|
enter | theory |
a(a). a(b). a(c). goe :- print(ingoX), nl, a(X), (print(X), print('X'), nl -> fail ; print(ingoaltX), nl), fail. goe :- print(ingo2X), nl. |
|
enter | query | goe. | |
check | hasSolutionWithOutput | true | |
check | output | ingoX aX bX cX ingo2X |
|
enter | theory |
a(a). a(b). a(c). b(bbb). gof :- print(aaa), nl, a(X), (print(hasAA_), print(X), nl, !, b(B), print(hasBB_), print(B), nl, fail ; print(altern)) ; print(alternate),nl,fail. gof :- print(a222), nl. |
|
enter | query | gof. | |
check | hasSolutionWithOutput | false | |
check | output | aaa hasAA_a hasBB_bbb |
|
enter | theory |
a(a). a(b). a(c). b(bbb). gog :- print(aaa), nl, a(X), (print(hasAA_), print(X), nl, b(B), print(hasBB_), print(B), nl, fail ; print(altern), nl, fail) ; print(alternate), nl, fail. gog :- print(a222), nl. |
|
enter | query | gog. | |
check | hasSolutionWithOutput | true | |
check | output | aaa hasAA_a hasBB_bbb altern hasAA_b hasBB_bbb altern hasAA_c hasBB_bbb altern alternate a222 |
|
enter | theory |
a(a). a(b). a(c). goh :- print(ingoX), nl, (a(X), print(X), print('X'), nl -> print(good) ; a(X), print(why_), print(X), nl, fail), fail. goh :- print(ingo2X), nl. |
|
enter | query | goh. | |
check | hasSolutionWithOutput | true | |
check | output | ingoX aX goodingo2X |
|
enter | theory |
a(a). a(b). a(c). goi :- print(ingoi), nl, a(X), print(X), nl -> (print(gotit), nl ; print(again), nl, fail). goi :- print(ingoi222), nl. |
|
enter | query | goi. | |
check | hasSolutionWithOutput | true | |
check | output | ingoi a gotit |
|
check | hasAnotherSolutionWithOutput | true | This mimick the behavior of GNU Prolog, but note that SICStus Prolog and SWI-Prolog do not provide another solution. |
check | output | again ingoi222 |
|
enter | theory |
a(a). a(b). a(c). goj :- print(ingoj), nl, !, (a(X), print(X), nl -> (print(gotit), nl ; print(again), nl), fail). goj :- print(ingoj222), nl. |
|
enter | query | goj. | |
check | hasSolutionWithOutput | false | |
check | output | ingoj a gotit again |
|
enter | theory |
a(a). a(b). a(c). gok :- print(ingoj), nl, !, (a(X), print(X), nl, (print(gotit), nl ; print(again), nl), fail). gok :- print(ingoj222), nl. |
|
enter | query | gok. | |
check | hasSolutionWithOutput | false | |
check | output | ingoj a gotit again b gotit again c gotit again |
|
enter | theory |
gol :- goll. gol :- print(golc2), nl. goll :- print(first), nl, gocp, fail ; print(ingol), nl, gocp, fail ; (print(lc), nl -> fail ; print(howdidwegethere1)), nl ; print(howhow), nl, fail. goll :- print(howdidwegethere2), nl. gocp :- print(gocpa), nl ; print(gocpb), nl. |
|
enter | query | gol. | |
check | hasSolutionWithOutput | true | |
check | output | first gocpa gocpb ingol gocpa gocpb lc howhow howdidwegethere2 |
|
check | hasAnotherSolutionWithOutput | true | This mimick the behavior of GNU Prolog, but note that SICStus Prolog and SWI-Prolog do not provide another solution. |
check | output | golc2 |
The following tests exercise Prolog meta-interpreters.
First of all, let's start an appropriate fixture containing an engine.
fit.ActionFixture | |
start | alice.tuprolog.EngineFixture |
Then, ask the engine to solve a query, and check variable bindings.
alice.tuprolog.PrologActionFixture | ||
enter | theory |
search(E, [E|_]). search(E, [_|T]) :- search(E, T). solve(true). solve((A, B)) :- !, solve(A), solve(B). solve(G) :- clause(G, B), solve(B). |
enter | query | solve(search(X, [1,2,3,1])). |
check | hasSolution | true |
enter | variable | X |
check | binding | 1 |
check | hasAnotherSolution | true |
enter | variable | X |
check | binding | 2 |
check | hasAnotherSolution | true |
enter | variable | X |
check | binding | 3 |
check | hasAnotherSolution | true |
enter | variable | X |
check | binding | 1 |
check | hasAnotherSolution | false |
The following tests exercise method access via reflection using JavaLibrary.
In particular, a test for accessing public methods of inner classes is performed. The JVM bug 4071957 prevents reflective access to inner classes public methods from a number of different scopes. This test exercises a sensible workaround for that bug implemented in JavaLibrary, in particular in the predicate java_class/3.
First of all, let's start an appropriate fixture containing an engine.
fit.ActionFixture | |
start | alice.tuprolog.EngineFixture |
Then, ask the engine to solve a query, and check variable bindings.
alice.tuprolog.PrologActionFixture | ||
enter | theory |
test_map(Size) :- java_object('java.util.HashMap', [], map), map <- put('key1', 'value1'), map <- put('key2', 'value2'), map <- put('key3', 'value3'), map <- entrySet returns entries, entries <- size returns Size. |
enter | query | test_map(S). |
check | hasSolution | true |
enter | variable | S |
check | binding | 3 |
The following tests exercise the univ (..=) operator to catch use cases that the ISO standard examples have missed.
In particular, the tests exercise the case where the first argument is an atomic term (i.e. an atom or a number) and the second argument is a variable, or a one-element-long list containing a variable.
First of all, let's start an appropriate fixture containing an engine.
fit.ActionFixture | |
start | alice.tuprolog.EngineFixture |
Then, ask the engine to solve a query, and check variable bindings.
alice.tuprolog.PrologActionFixture | ||
enter | query | a =.. L. |
check | hasSolution | true |
enter | variable | L |
check | binding | [a] |
enter | query | 3 =.. L. |
check | hasSolution | true |
enter | variable | L |
check | binding | [3] |
enter | query | a =.. [X]. |
check | hasSolution | true |
enter | variable | X |
check | binding | a |
The results of the tests for Bugs are as follows:
fit.Summary |