Tests Vars

Jan Burse, created Aug 18. 2019
/**
* Prolog code for the msic text test cases.
*
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies GmbH makes no warranties
* regarding the provided information. XLOG Technologies GmbH assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies GmbH.
*
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies GmbH. If the company was not the originator of some
* excerpts, XLOG Technologies GmbH has at least obtained the right to
* reproduce, change and translate the information.
*
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
*
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
*
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies GmbH.
*/
:- use_package(library(jekdev/reference/testing)).
:- multifile runner:ref/4.
:- discontiguous runner:ref/4.
:- multifile runner:case/4.
:- discontiguous runner:case/4.
/* numbervars(T, N, M) */
runner:ref(numbervars, 3, extra_vars, 'XLOG 3.1.1').
runner:case(numbervars, 3, extra_vars, 'XLOG 3.1.1, XLOG 1') :-
numbervars(f(X, X, Y), 0, N),
X == '$VAR'(0), Y == '$VAR'(1), N == 2.
runner:case(numbervars, 3, extra_vars, 'XLOG 3.1.1, XLOG 2') :-
numbervars(f(Y, X, X), 10, N),
Y == '$VAR'(10), X == '$VAR'(11), N == 12.
runner:case(numbervars, 3, extra_vars, 'XLOG 3.1.1, XLOG 3') :-
catch(numbervars(_, a, _), error(E, _), true),
nonvar(E), E = type_error(integer, _).
runner:case(numbervars, 3, extra_vars, 'XLOG 3.1.1, XLOG 4') :-
catch(numbervars(_, -2, _), error(E, _), true),
E == representation_error(not_less_than_zero).
/* A *-> B */
runner:ref(*->, 2, extra_vars, 'XLOG 3.2.1').
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 1') :-
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 2') :-
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 3') :-
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 4a') :-
(true *-> X = 1), X == 1.
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 4b') :-
findall(X, (true *-> X = 1), [_]).
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 5a') :-
((X = 1; X = 2) *-> true), X == 1.
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 5b') :-
findall(X, ((X = 1; X = 2) *-> true), [_, X|_]), X == 2.
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 5c') :-
findall(X, ((X = 1; X = 2) *-> true), [_, _]).
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 6a') :-
(true *-> (X = 1; X = 2)), X == 1.
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 6b') :-
findall(X, (true *-> (X = 1; X = 2)), [_, X|_]), X == 2.
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, ISO 6c') :-
findall(X, (true *-> (X = 1; X = 2)), [_, _]).
runner:case(*->, 2, extra_vars, 'XLOG 3.2.1, XLOG 1') :-
findall(X-Y, ((Y = 1; Y = 2), ((X = 1, !; X = 2) *-> true)), [_, _]).
/* A *-> B ; C */
runner:ref(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2').
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 1') :-
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 2') :-
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 3') :-
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 4') :-
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 5') :-
(true *-> X = 1; X = 2), X == 1.
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 6') :-
(fail *-> X = 1; X = 2), X == 2.
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 7a') :-
(true *-> (X = 1; X = 2); true), X == 1.
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 7b') :-
findall(X, (true *-> (X = 1; X = 2); true), [_, X|_]), X == 2.
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 7c') :-
findall(X, (true *-> (X = 1; X = 2); true), [_, _]).
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 8a') :-
((X = 1; X = 2) *-> true; true), X == 1.
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 8b') :-
findall(X, ((X = 1; X = 2) *-> true; true), [_, X|_]), X == 2.
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 8C') :-
findall(X, ((X = 1; X = 2) *-> true; true), [_, _]).
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, ISO 9') :-
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, XLOG 1') :-
findall(X-Y, ((Y = 1; Y = 2), ((X = 1; X = 2) *-> true; true)), [_, _, _, _]).
runner:case(soft_if_then_else, 3, extra_vars, 'XLOG 3.2.2, XLOG 2') :-
findall(X-Y, ((Y = 1; Y = 2), ((X = 1, !; X = 2) *-> true; true)), [_, _]).

Comments