Prolog "markup"

         
/**
* 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(common, markup, 'XLOG 2.3 markup streams').
/****************************************************************/
/* Stream Formatter */
/****************************************************************/
/* format(X, Y) */
runner_pred(format, 2, common, markup, 'XLOG 2.3.1').
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 1') :-
open_output_atom_stream(S),
format(S, 'abc ~4e', [0.499999]),
close_output_atom_stream(S, X),
X == 'abc 5.0000e-1'.
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 2') :-
open_output_atom_stream(S),
format(S, '~4f def', [49.9999]),
close_output_atom_stream(S, X),
X == '49.9999 def'.
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 3') :-
open_output_atom_stream(S),
format(S, 'abc ~4g def', [4.99999E10]),
close_output_atom_stream(S, X),
X == 'abc 5e10 def'.
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 4') :-
open_output_atom_stream(S),
format(S, 'abc ~~ ~f def', [49.9999]),
close_output_atom_stream(S, X),
X == 'abc ~ 49.999900 def'.
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 5') :-
open_output_atom_stream(S),
format(S, 'abc ~w def ~q', ['X','Y']),
close_output_atom_stream(S, X),
X == 'abc X def ''Y'''.
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 6') :-
open_output_atom_stream(S),
format(S, 'foo?bar=~c', ['1=2']),
close_output_atom_stream(S, X),
X == 'foo?bar=1%3D2'.
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 7') :-
open_output_atom_stream(S),
catch(format(S, '~y', [123.456]), error(E,_), true),
E == existence_error(format_character, y).
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 8') :-
open_output_atom_stream(S),
format(S, 'tag ~a header level 1', ['<h1>']),
close_output_atom_stream(S, X),
X == 'tag &lt;h1&gt; header level 1'.
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 9') :-
open_output_atom_stream(S),
catch(format(S, 'abc ~w def', [a,b]), error(E,_), true),
E == syntax_error(aguments_mismatch).
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 10') :-
open_output_atom_stream(S),
format(S, 'abc ~4f def~n', [2*pi]),
close_output_atom_stream(S, X),
X == 'abc 6.2832 def\n'.
runner_case(format, 2, common, markup, 'XLOG 2.3.1, XLOG 11') :-
open_output_atom_stream(S),
catch(format(S, 'abc ~d def', [1.2]), error(E,_), true),
E == type_error(integer, 1.2).
/* format_atom(X, Y, Z) */
runner_pred(format_atom, 3, common, markup, 'XLOG 2.3.2').
runner_case(format_atom, 3, common, markup, 'XLOG 2.3.2, XLOG 1') :-
format_atom('abc ~w def', [1+2], X),
X == 'abc 1+2 def'.
runner_case(format_atom, 3, common, markup, 'XLOG 2.3.2, XLOG 2') :-
format_atom('abc ~k def ~2r', [1+2,7], X),
X == 'abc +(1, 2) def 111'.
runner_case(format_atom, 3, common, markup, 'XLOG 2.3.2, XLOG 3') :-
format_atom('~0f ~0f def', [1.5, 2.5], X),
X == '2 2 def'.
runner_case(format_atom, 3, common, markup, 'XLOG 2.3.2, XLOG 4') :-
catch(format_atom(_, [1+2], 'abc 1+2 def'), error(E,_), true),
E == instantiation_error.
runner_case(format_atom, 3, common, markup, 'XLOG 2.3.2, XLOG 5') :-
catch(format_atom('abc ~w def', [], _), error(E,_), true),
E == syntax_error(aguments_mismatch).
/****************************************************************/
/* Ascii Sink */
/****************************************************************/
/* tag(A) */
runner_pred(tag,1, common, markup, 'XLOG 2.3.3').
runner_case(tag,1, common, markup, 'XLOG 2.3.3, XLOG 1') :-
open_output_atom_stream(S),
tag(S, '<span class="vr">'), write(S, 'foo'), tag(S, '</span>'),
close_output_atom_stream(S, X),
X == '\33\[38;2;0;136;136mfoo\33\[39m'.
runner_case(tag,1, common, markup, 'XLOG 2.3.3, XLOG 2') :-
open_output_atom_stream(S),
tag(S, '&amp;'),
close_output_atom_stream(S, X),
X == '&' .
runner_case(tag,1, common, markup, 'XLOG 2.3.3, XLOG 3') :-
open_output_atom_stream(S),
tag(S, 'John <i>Doe</i>'),
close_output_atom_stream(S, X),
X == 'John \33\[3mDoe\33\[23m'.
runner_case(tag,1, common, markup, 'XLOG 2.3.3, XLOG 4') :-
open_output_atom_stream(S),
catch(tag(S, '<foo'), error(E,_), true),
E == syntax_error(missing_angle).
/****************************************************************/
/* XML Sink */
/****************************************************************/
/* dom_output_new(S, W) */
runner_pred(dom_output_new,2, common, markup, 'XLOG 2.3.4').
runner_case(dom_output_new,2, common, markup, 'XLOG 2.3.4, XLOG 1') :-
open_output_atom_stream(S), dom_output_new(S, W),
write(W, 'foo<bar>baz'),
flush_output(W), sys_output_atom_stream_get(S, X),
X == 'foo&lt;bar&gt;baz'.
runner_case(dom_output_new,2, common, markup, 'XLOG 2.3.4, XLOG 2') :-
open_output_atom_stream(S), dom_output_new(S, W),
tag(W, '<p>'), write(W, 'foo'), tag(W, '</p>'),
flush_output(W), sys_output_atom_stream_get(S, X),
X == '<p>foo</p>\n'.