Prolog "struc"

         
/**
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies AG makes no warranties
* regarding the provided information. XLOG Technologies AG assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies AG.
*
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies AG. If the company was not the originator of some
* excerpts, XLOG Technologies AG 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 AG.
*/
:- multifile runner_case/5.
:- discontiguous(runner_case/5).
:- multifile(runner_pred/5).
:- discontiguous(runner_pred/5).
:- multifile(runner_file/3).
runner_file(adapter, struc, 'XLOG 1.4 atoms').
/****************************************************************/
/* atom extras */
/****************************************************************/
/* last_sub_atom(X, Y, Z, T, U) */
/* derived from sub_atom/5 test cases. */
runner_pred(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1').
runner_case(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1, XLOG 1') :-
last_sub_atom(abracadabra, 0, 5, _, S),
S == abrac.
runner_case(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1, XLOG 2') :-
last_sub_atom(abracadabra, _, 5, 0, S),
S == dabra.
runner_case(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1, XLOG 3') :-
last_sub_atom(abracadabra, 3, L, 3, S),
L == 5, S == acada.
runner_case(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1, XLOG 4a') :-
last_sub_atom(abracadabra, B, 2, A, ab), !,
B == 7, A == 2.
runner_case(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1, XLOG 4b') :-
findall(A-B,last_sub_atom(abracadabra, B, 2, A, ab),[_,A-B|_]),
B == 0, A == 9.
runner_case(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1, XLOG 5') :-
last_sub_atom('Banana', 3, 2, _, S),
S == 'an'.
runner_case(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1, XLOG 6a') :-
last_sub_atom(charity, _, 3, _, S), !,
S == 'ity'.
runner_case(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1, XLOG 6b') :-
findall(S,last_sub_atom(charity, _, 3, _, S),[_,S|_]),
S == 'rit'.
runner_case(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1, XLOG 7a') :-
last_sub_atom(ab, Start, Length, _, Sub_atom), !,
Start == 2, Length == 0, Sub_atom == ''.
runner_case(last_sub_atom, 5, adapter, struc, 'XLOG 1.4.1, XLOG 7b') :-
findall(Start-Length-Sub_atom, last_sub_atom(ab, Start, Length, _, Sub_atom),
[_,Start-Length-Sub_atom|_]),
Start == 1, Length == 1, Sub_atom == 'b'.
/* atom_join(X, Y) */
runner_pred(atom_join, 2, adapter, struc, 'XLOG 1.4.2').
runner_case(atom_join, 2, adapter, struc, 'XLOG 1.4.2, XLOG 1') :-
atom_join([foo,bar], X),
X == 'foobar'.
runner_case(atom_join, 2, adapter, struc, 'XLOG 1.4.2, XLOG 2') :-
\+ atom_join([bar,baz], 'foobar').
runner_case(atom_join, 2, adapter, struc, 'XLOG 1.4.2, XLOG 3') :-
catch(atom_join(foo, _), error(E,_), true),
E == type_error(list,foo).
/****************************************************************/
/* term extras */
/****************************************************************/
/* term_hash(X, Y) */
runner_pred(term_hash,2, adapter, struc, 'XLOG 1.4.3').
runner_case(term_hash,2, adapter, struc, 'XLOG 1.4.3, XLOG 1') :-
X = "abc", term_hash(X, H),
H == 144646.
runner_case(term_hash,2, adapter, struc, 'XLOG 1.4.3, XLOG 2') :-
term_hash(f, J), term_hash(X, H), term_hash(f(X), K),
K =:= J*31+H.
runner_case(term_hash,2, adapter, struc, 'XLOG 1.4.3, XLOG 3') :-
X is -(2^41*3), term_hash(X, H),
H = -47616.
runner_case(term_hash,2, adapter, struc, 'XLOG 1.4.3, XLOG 4') :-
X = [97, 98, 99|X], term_hash(X, H),
H == 143255.
runner_case(term_hash,2, adapter, struc, 'XLOG 1.4.3, XLOG 5') :-
X is -inf, term_hash(X, Y),
Y == -1048576.
runner_case(term_hash,2, adapter, struc, 'XLOG 1.4.3, XLOG 6') :-
term_hash('𝄞', X),
X == 1772394.
runner_case(term_hash,2, adapter, struc, 'XLOG 1.4.3, XLOG 7') :-
X = f(X,a), Y = g(b,X,Y), term_hash(Y, H),
H == 6505664.