Prolog "intnum"
Admin User, created Apr 07. 2025
/**
* 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.
*/
runner_file(extra, intnum, 'XLOG 3.2 intnum').
/****************************************************************/
/* intatom.p extras */
/****************************************************************/
/* reference */
/* derived from callable/1 test cases. */
runner_pred(reference, 1, extra, intnum, 'XLOG 3.2.1').
runner_case(reference, 1, extra, intnum, 'XLOG 3.2.1, XLOG 1') :-
current_input(R), reference(R).
runner_case(reference, 1, extra, intnum, 'XLOG 3.2.1, XLOG 2') :-
\+ reference(3).
runner_case(reference, 1, extra, intnum, 'XLOG 3.2.1, XLOG 3') :-
\+ reference(_).
runner_case(reference, 1, extra, intnum, 'XLOG 3.2.1, XLOG 4') :-
\+ reference((1,2)).
runner_case(reference, 1, extra, intnum, 'XLOG 3.2.1, XLOG 5') :-
\+ reference('string').
/* atom_integer(X, Y, Z) */
runner_pred(atom_integer, 3, extra, intnum, 'XLOG 3.2.2').
runner_case(atom_integer, 3, extra, intnum, 'XLOG 3.2.2, XLOG 1') :-
atom_integer(T, 10, 33), T == '33'.
runner_case(atom_integer, 3, extra, intnum, 'XLOG 3.2.2, XLOG 2') :-
atom_integer('-25', 10, A), A == -25.
runner_case(atom_integer, 3, extra, intnum, 'XLOG 3.2.2, XLOG 3') :-
atom_integer(X, 16, 47806), X == 'babe'.
runner_case(atom_integer, 3, extra, intnum, 'XLOG 3.2.2, XLOG 4') :-
atom_integer('BABE', 16, X), X = 47806.
runner_case(atom_integer, 3, extra, intnum, 'XLOG 3.2.2, XLOG 5') :-
catch(atom_integer('1+2', 10, _), error(E,_), true),
E == syntax_error(illegal_number).
runner_case(atom_integer, 3, extra, intnum, 'XLOG 3.2.2, XLOG 6') :-
catch(atom_integer(foo(bar), 10, _), error(E, _), true),
E == type_error(atom, foo(bar)).
runner_case(atom_integer, 3, extra, intnum, 'XLOG 3.2.2, XLOG 7') :-
catch(atom_integer(_, _, 33), error(E, _), true),
E == instantiation_error.
runner_case(atom_integer, 3, extra, intnum, 'XLOG 3.2.2, XLOG 8') :-
catch(atom_integer('25', 0, _), error(E,_), true),
E == domain_error(radix, 0).
runner_case(atom_integer, 3, extra, intnum, 'XLOG 3.2.2, XLOG 9') :-
atom_integer('012', 10, 12).
/*******************************************************************/
/* Code Type etc.. */
/*******************************************************************/
/* code_category(C, T) */
runner_pred(code_category,2, extra, intnum, 'XLOG 3.2.3').
runner_case(code_category,2, extra, intnum, 'XLOG 3.2.3, XLOG 1') :-
code_category(0' ,T), T == 12.
runner_case(code_category,2, extra, intnum, 'XLOG 3.2.3, XLOG 2') :-
code_category(0'\n, T), T == 15.
runner_case(code_category,2, extra, intnum, 'XLOG 3.2.3, XLOG 3') :-
code_category(0'!, T), T == 24.
runner_case(code_category,2, extra, intnum, 'XLOG 3.2.3, XLOG 4') :-
code_category(0'A, T), T == 1.
runner_case(code_category,2, extra, intnum, 'XLOG 3.2.3, XLOG 5') :-
code_category(0x200000, T), T == 0.
runner_case(code_category,2, extra, intnum, 'XLOG 3.2.3, XLOG 6') :-
catch(code_category(_,_), error(E,_), true),
E == instantiation_error.
runner_case(code_category,2, extra, intnum, 'XLOG 3.2.3, XLOG 7') :-
catch(code_category(foo,_), error(E,_), true),
E == type_error(integer, foo).
/* code_numeric(C, V) */
runner_pred(code_numeric,2, extra, intnum, 'XLOG 3.2.4').
runner_case(code_numeric,2, extra, intnum, 'XLOG 3.2.4, XLOG 1') :-
code_numeric(0'a, V), V == 10.
runner_case(code_numeric,2, extra, intnum, 'XLOG 3.2.4, XLOG 2') :-
code_numeric(0'9, V), V == 9.
runner_case(code_numeric,2, extra, intnum, 'XLOG 3.2.4, XLOG 3') :-
code_numeric(0'=, V), V == -1.
runner_case(code_numeric,2, extra, intnum, 'XLOG 3.2.4, XLOG 4') :-
code_numeric(0x0D75, V), V == -1.
runner_case(code_numeric,2, extra, intnum, 'XLOG 3.2.4, XLOG 5') :-
code_numeric(0x216E, V), V == -1.
runner_case(code_numeric,2, extra, intnum, 'XLOG 3.2.4, XLOG 6') :-
code_numeric(0x200000, V), V == -1.
runner_case(code_numeric,2, extra, intnum, 'XLOG 3.2.4, XLOG 7') :-
catch(code_numeric(_,_), error(E,_), true),
E == instantiation_error.
runner_case(code_numeric,2, extra, intnum, 'XLOG 3.2.4, XLOG 8') :-
catch(code_numeric(foo,_), error(E,_), true),
E == type_error(integer, foo).
/****************************************************************/
/* Time Atoms */
/****************************************************************/
/* atom_time(S, F, T) mode (-, +, +) */
runner_pred(sys_time_format , 3, extra, intnum, 'XLOG 3.2.5').
runner_case(sys_time_format , 3, extra, intnum, 'XLOG 3.2.5, XLOG 1') :-
atom_time(X, '%d/%m/%Y', 1699965488687),
X == '14/11/2023'.
runner_case(sys_time_format , 3, extra, intnum, 'XLOG 3.2.5, XLOG 2') :-
atom_time(X, '%d.%m.%Y %H:%M', 1699965488687),
X == '14.11.2023 13:38'.
runner_case(sys_time_format , 3, extra, intnum, 'XLOG 3.2.5, XLOG 3') :-
atom_time(X, '%a, %d %b %Y %H:%M:%S', 1727128257073),
X == 'Mo, 23 Sep 2024 23:50:57'.
runner_case(sys_time_format , 3, extra, intnum, 'XLOG 3.2.5, XLOG 4') :-
catch(atom_time(_, 'foo %i bar', 1727288982799), error(E,_), true),
E == domain_error(time_format, 'foo %i bar').
runner_case(sys_time_format , 3, extra, intnum, 'XLOG 3.2.5, XLOG 5') :-
catch(atom_time(1699965488687, '%d.%m.%Y %H:%M', _), error(E,_), true),
E == type_error(atom, 1699965488687).
/* atom_time(S, F, T) mode (+, +, -) */
runner_pred(sys_time_parse, 3, extra, intnum, 'XLOG 3.2.6').
runner_case(sys_time_parse, 3, extra, intnum, 'XLOG 3.2.6, XLOG 1') :-
atom_time('14/11/2023', '%d/%m/%Y', X),
X = 1699916400000.
runner_case(sys_time_parse, 3, extra, intnum, 'XLOG 3.2.6, XLOG 2') :-
atom_time('14.11.2023 13:38', '%d.%m.%Y %H:%M', X),
X = 1699965480000.
runner_case(sys_time_parse, 3, extra, intnum, 'XLOG 3.2.6, XLOG 3') :-
catch(atom_time('14.11. 13:38', '%d.%m.%Y %H:%M', _), error(E,_), true),
E == syntax_error(illegal_date).
runner_case(sys_time_parse, 3, extra, intnum, 'XLOG 3.2.6, XLOG 4') :-
atom_time('Mo, 23 Sep 2024 23:50:57', '%a, %d %b %Y %H:%M:%S', X),
X == 1727128257000.
runner_case(sys_time_parse, 3, extra, intnum, 'XLOG 3.2.6, XLOG 5') :-
catch(atom_time('Mo, 23 2024 23:50:57', '%a, %d %b %Y %H:%M:%S', _), error(E,_), true),
E == syntax_error(illegal_date).
runner_case(sys_time_parse, 3, extra, intnum, 'XLOG 3.2.6, XLOG 6') :-
atom_time('Mo, 23 sep 2024 23:50:57', '%a, %d %b %Y %H:%M:%S', X),
X == 1727128257000.
runner_case(sys_time_parse, 3, extra, intnum, 'XLOG 3.2.6, XLOG 7') :-
atom_time('%-%', '%%-%%', X),
X == -2208992400000.
runner_case(sys_time_parse, 3, extra, intnum, 'XLOG 3.2.6, XLOG 8') :-
catch(atom_time(_, '%d.%m.%Y %H:%M', '14/11/2023'), error(E,_), true),
E == type_error(integer, '14/11/2023').