Tests Regex

Jan Burse, erstellt 18. Aug 2019
/**
* Prolog code for the extra regex 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.
:- use_module(library(misc/text)).
/*******************************************************************/
/* Char Type etc.. */
/*******************************************************************/
/* char_class(C, N) */
runner:ref(char_class, 2, extra_regex, 'XLOG 2.1.1').
runner:case(char_class, 2, extra_regex, 'XLOG 2.1.1, XLOG 1') :-
char_class(' ', N), N == blank.
runner:case(char_class, 2, extra_regex, 'XLOG 2.1.1, XLOG 2') :-
char_class('\n', N), N == cntrl.
runner:case(char_class, 2, extra_regex, 'XLOG 2.1.1, XLOG 3') :-
char_class('\xFFFE\', N), N == inval.
runner:case(char_class, 2, extra_regex, 'XLOG 2.1.1, XLOG 4') :-
char_class(!, N), N == solo.
runner:case(char_class, 2, extra_regex, 'XLOG 2.1.1, XLOG 5') :-
char_class('A', N), N == upper.
runner:case(char_class, 2, extra_regex, 'XLOG 2.1.1, XLOG 6') :-
catch(char_class(_, _), error(E, _), true),
nonvar(E), E = instantiation_error.
runner:case(char_class, 2, extra_regex, 'XLOG 2.1.1, XLOG 7') :-
catch(char_class(77, _), error(E, _), true),
nonvar(E), E = type_error(atom, _).
/* unicode >0xFFFF, deseret alphabet */
runner:case(char_class, 2, extra_regex, 'XLOG 2.1.1, XLOG 8') :-
char_class(๐ฌ, N), N == lower.
/* code_class(C, N) */
runner:ref(code_class, 2, extra_regex, 'XLOG 2.1.2').
runner:case(code_class, 2, extra_regex, 'XLOG 2.1.2, XLOG 1') :-
code_class(0'_, N), N == score.
runner:case(code_class, 2, extra_regex, 'XLOG 2.1.2, XLOG 2') :-
code_class(0'a, N), N == lower.
runner:case(code_class, 2, extra_regex, 'XLOG 2.1.2, XLOG 3') :-
code_class(0'ยผ, N), N == other.
runner:case(code_class, 2, extra_regex, 'XLOG 2.1.2, XLOG 4') :-
code_class(0'0, N), N == digit.
runner:case(code_class, 2, extra_regex, 'XLOG 2.1.2, XLOG 5') :-
code_class(0'=, N), N == symbol.
runner:case(code_class, 2, extra_regex, 'XLOG 2.1.2, XLOG 6') :-
catch(code_class(_, _), error(E, _), true),
nonvar(E), E = instantiation_error.
runner:case(code_class, 2, extra_regex, 'XLOG 2.1.2, XLOG 7') :-
catch(code_class(foo, _), error(E, _), true),
nonvar(E), E = type_error(integer, _).
/* unicode >0xFFFF, deseret alphabet */
runner:case(code_class, 2, extra_regex, 'XLOG 2.1.2, XLOG 8') :-
code_class(0'๐„, N), N == upper.
/*******************************************************************/
/* Code Upper etc.. */
/*******************************************************************/
/* code_upper(C, D) */
runner:ref(code_upper, 2, extra_regex, 'XLOG 2.2.1').
runner:case(code_upper, 2, extra_regex, 'XLOG 2.2.1, XLOG 1') :-
code_upper(0'_, D), D == 0'_.
runner:case(code_upper, 2, extra_regex, 'XLOG 2.2.1, XLOG 2') :-
code_upper(0xFFFE, D), D == 0xFFFE.
runner:case(code_upper, 2, extra_regex, 'XLOG 2.2.1, XLOG 3') :-
code_upper(0'a, D), D == 0'A.
runner:case(code_upper, 2, extra_regex, 'XLOG 2.2.1, XLOG 4') :-
code_upper(0'A, D), D == 0'A.
runner:case(code_upper, 2, extra_regex, 'XLOG 2.2.1, XLOG 5') :-
catch(code_upper(_, _), error(E, _), true),
nonvar(E), E = instantiation_error.
/* unicode >0xFFFF, deseret alphabet */
runner:case(code_upper, 2, extra_regex, 'XLOG 2.2.1, XLOG 6') :-
code_upper(0'๐ฌ, D), D == 0'๐„.
/* code_lower(C, D) */
runner:ref(code_lower, 2, extra_regex, 'XLOG 2.2.2').
runner:case(code_lower, 2, extra_regex, 'XLOG 2.2.2, XLOG 1') :-
code_lower(0'=, D), D == 0'= .
runner:case(code_lower, 2, extra_regex, 'XLOG 2.2.2, XLOG 2') :-
code_lower(0'0, D), D == 0'0.
runner:case(code_lower, 2, extra_regex, 'XLOG 2.2.2, XLOG 3') :-
code_lower(0'a, D), D == 0'a.
runner:case(code_lower, 2, extra_regex, 'XLOG 2.2.2, XLOG 4') :-
code_lower(0'A, D), D == 0'a.
runner:case(code_lower, 2, extra_regex, 'XLOG 2.2.2, XLOG 5') :-
catch(code_lower(foo, _), error(E, _), true),
nonvar(E), E = type_error(integer, _).
/* unicode >0xFFFF, deseret alphabet */
runner:case(code_lower, 2, extra_regex, 'XLOG 2.2.2, XLOG 6') :-
code_lower(0'๐„, D), D == 0'๐ฌ.
/* upcase_atom(A, B) */
runner:ref(upcase_atom, 2, extra_regex, 'XLOG 2.2.3').
runner:case(upcase_atom, 2, extra_regex, 'XLOG 2.2.3, XLOG 1') :-
upcase_atom('_A7', D), D == '_A7'.
runner:case(upcase_atom, 2, extra_regex, 'XLOG 2.2.3, XLOG 2') :-
upcase_atom('\xFFFE\', D), D == '\xFFFE\'.
runner:case(upcase_atom, 2, extra_regex, 'XLOG 2.2.3, XLOG 3') :-
upcase_atom(abc, D), D == 'ABC'.
runner:case(upcase_atom, 2, extra_regex, 'XLOG 2.2.3, XLOG 4') :-
upcase_atom('ABC', D), D == 'ABC'.
runner:case(upcase_atom, 2, extra_regex, 'XLOG 2.2.3, XLOG 5') :-
catch(upcase_atom(_, _), error(E, _), true),
nonvar(E), E = instantiation_error.
/* unicode >0xFFFF, deseret alphabet */
runner:case(upcase_atom, 2, extra_regex, 'XLOG 2.2.3, XLOG 6') :-
upcase_atom(๐ซ๐ฌ๐ญ, D), D == '๐ƒ๐„๐…'.
/* downcase_atom(A, B) */
runner:ref(downcase_atom, 2, extra_regex, 'XLOG 2.2.4').
runner:case(downcase_atom, 2, extra_regex, 'XLOG 2.2.4, XLOG 1') :-
downcase_atom(=<, D), D == =< .
runner:case(downcase_atom, 2, extra_regex, 'XLOG 2.2.4, XLOG 2') :-
downcase_atom('123', D), D == '123'.
runner:case(downcase_atom, 2, extra_regex, 'XLOG 2.2.4, XLOG 3') :-
downcase_atom(abc, D), D == abc.
runner:case(downcase_atom, 2, extra_regex, 'XLOG 2.2.4, XLOG 4') :-
downcase_atom('ABC', D), D == abc.
runner:case(downcase_atom, 2, extra_regex, 'XLOG 2.2.4, XLOG 5') :-
catch(downcase_atom(77, _), error(E, _), true),
nonvar(E), E = type_error(atom, _).
/* unicode >0xFFFF, deseret alphabet */
runner:case(downcase_atom, 2, extra_regex, 'XLOG 2.2.4, XLOG 6') :-
downcase_atom('๐ƒ๐„๐…', D), D == ๐ซ๐ฌ๐ญ.
/*******************************************************************/
/* Create Patern Match etc.. */
/*******************************************************************/
/* pattern_match(S, P) */
/* default settings */
runner:ref(pattern_match, 2, extra_regex, 'XLOG 2.3.1').
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 1') :-
\+ pattern_match(foobarbaz, bar).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 2') :-
\+ pattern_match(foobarbaz, 'bar*').
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 3') :-
pattern_match(foobarbaz, '*bar*').
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 4') :-
\+ pattern_match(foobarbaz, baz).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 5') :-
\+ pattern_match(foobarbaz, 'baz*').
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 6') :-
pattern_match(foobarbaz, '*baz*').
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 7') :-
\+ pattern_match(foobarbaz, foo).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 8') :-
pattern_match(foobarbaz, 'foo*').
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 9') :-
pattern_match('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '*๐ƒ๐„๐…*').
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 10') :-
\+ pattern_match('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐†๐‡๐ˆ*').
/* setting ignore_case=true */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 11') :-
\+ pattern_match('FOOBARBAZ', '*bar', [ignore_case(true)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 12') :-
pattern_match(foobarbaz, '*BAZ', [ignore_case(true)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 13') :-
\+ pattern_match('FOOBARBAZ', '*foo', [ignore_case(true)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 14') :-
pattern_match(foobarbaz, '*FOO*', [ignore_case(true)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 15') :-
pattern_match('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '*๐ซ๐ฌ๐ญ*', [ignore_case(true)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 16') :-
\+ pattern_match('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐ฎ๐ฏ๐ฐ*', [ignore_case(true)]).
/* setting boundary=part */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 17') :-
\+ pattern_match(foobarbaz, tak, [boundary(part)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 18') :-
pattern_match(foobarbaz, bar, [boundary(part)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 19') :-
pattern_match(foobarbaz, foo, [boundary(part)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 20') :-
pattern_match(foobarbaz, baz, [boundary(part)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 21') :-
pattern_match('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐ƒ๐„๐…', [boundary(part)]).
/* setting boundary=word */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 22') :-
\+ pattern_match('foo bar baz', tak, [boundary(word)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 23') :-
pattern_match('foo bar baz', bar, [boundary(word)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 24') :-
\+ pattern_match('foo barbaz', bar, [boundary(word)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 25') :-
pattern_match('foo bar baz', foo, [boundary(word)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 26') :-
\+ pattern_match('foobar baz', foo, [boundary(word)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 27') :-
pattern_match('foo bar baz', baz, [boundary(word)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 28') :-
\+ pattern_match('foo barbaz', baz, [boundary(word)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 29') :-
pattern_match('๐€๐๐‚ ๐ƒ๐„๐… ๐†๐‡๐ˆ', '๐ƒ๐„๐…', [boundary(word)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 30') :-
\+ pattern_match('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐ƒ๐„๐…', [boundary(word)]).
/* setting boundary=part, ignore_case=true */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 31') :-
pattern_match(foobarbaz, 'BAR', [boundary(part), ignore_case(true)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 32') :-
\+ pattern_match(foobarbaz, 'FOOBAZ', [boundary(part), ignore_case(true)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 33') :-
pattern_match('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', ๐ซ๐ฌ๐ญ, [boundary(part), ignore_case(true)]).
/* setting boundary=word, ignore_case=true */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 34') :-
pattern_match('foo bar baz', bar, [boundary(word), ignore_case(true)]).
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 35') :-
\+ pattern_match('foo bar baz', 'FOO BAZ', [boundary(word), ignore_case(true)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_match, 2, extra_regex, 'XLOG 2.3.1, XLOG 36') :-
pattern_match('๐€๐๐‚ ๐ƒ๐„๐… ๐†๐‡๐ˆ', ๐ซ๐ฌ๐ญ, [boundary(word), ignore_case(true)]).
/* pattern_replace(S, P, R, T) */
/* default settings */
runner:ref(pattern_replace, 4, extra_regex, 'XLOG 2.3.2').
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 1') :-
\+ pattern_replace(foobarbaz, '*bar', '*tok', _).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 2') :-
\+ pattern_replace(foobarbaz, 'bar*', 'tok*', _).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 3') :-
pattern_replace(foobarbaz, '*bar*', '*tok*', X), X == footokbaz.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 4') :-
\+ pattern_replace(foobarbaz, baz, tok, _).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 5') :-
pattern_replace(foobarbaz, '*baz', '*tok', X), X == foobartok.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 6') :-
pattern_replace(foobarbaz, '*baz*', '*tok*', X), X == foobartok.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 7') :-
\+ pattern_replace(foobarbaz, '*foo', '*tok', _).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 8') :-
pattern_replace(foobarbaz, '*foo*', '*tok*', X), X == tokbarbaz.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 9') :-
pattern_replace(foobarfoobar, '*foo*', '*tok*', X),
X == tokbarfoobar.
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 10') :-
pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '*๐ƒ๐„๐…*', '*๐Ž๐๐*', X),
X == '๐€๐๐‚๐Ž๐๐๐†๐‡๐ˆ'.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 11') :-
\+ pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐†๐‡๐ˆ*', '๐Ž๐๐*', _).
/* setting ignore_case=true */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 12') :-
\+ pattern_replace(foobarbaz, 'BAR', tok, _, [ignore_case(true)]).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 13') :-
\+ pattern_replace('FOOBARBAZ', 'baz*', 'tok*', _, [ignore_case(true)]).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 14') :-
\+ pattern_replace(foobarbaz, 'FOO', tok, _, [ignore_case(true)]).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 15') :-
pattern_replace('FOOBARBAZ', 'foo*', 'tok*', X, [ignore_case(true)]),
X == 'TOKBARBAZ'.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 16') :-
pattern_replace(foobarfoobar, '*BAR*', '*TOK*', X, [ignore_case(true)]),
X == footokfoobar.
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 17') :-
pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '*๐ซ๐ฌ๐ญ*', '*๐Ž๐๐*', X, [ignore_case(true)]),
X == '๐€๐๐‚๐ถ๐ท๐ธ๐†๐‡๐ˆ'.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 18') :-
\+ pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐ฎ๐ฏ๐ฐ*', '๐Ž๐๐*', _, [ignore_case(true)]).
/* setting boundary=part */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 19') :-
\+ pattern_replace(foobarbaz, tak, tok, _, [boundary(part)]).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 20') :-
pattern_replace(foobarbaz, bar, tok, X, [boundary(part)]),
X == footokbaz.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 21') :-
pattern_replace(foobarbaz, foo, tok, X, [boundary(part)]),
X == tokbarbaz.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 22') :-
pattern_replace(foobarbaz, baz, tok, X, [boundary(part)]),
X == foobartok.
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 23') :-
pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐ƒ๐„๐…', '๐Ž๐๐', X, [boundary(part)]),
X == '๐€๐๐‚๐Ž๐๐๐†๐‡๐ˆ'.
/* setting boundary=word */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 24') :-
\+ pattern_replace('foo bar baz', tak, tok, _, [boundary(word)]).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 25') :-
pattern_replace('foo bar baz', bar, tok, X, [boundary(word)]),
X == 'foo tok baz'.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 26') :-
\+ pattern_replace('foo barbaz', bar, tok, _, [boundary(word)]).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 27') :-
pattern_replace('foo bar baz', foo, tok, X, [boundary(word)]),
X == 'tok bar baz'.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 28') :-
\+ pattern_replace('foobar baz', foo, tok, _, [boundary(word)]).
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 29') :-
pattern_replace('foo bar baz', baz, tok, X, [boundary(word)]),
X == 'foo bar tok'.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 30') :-
\+ pattern_replace('foo barbaz', baz, tok, _, [boundary(word)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 31') :-
pattern_replace('๐€๐๐‚ ๐ƒ๐„๐… ๐†๐‡๐ˆ', '๐ƒ๐„๐…', '๐Ž๐๐', X, [boundary(word)]),
X == '๐€๐๐‚ ๐Ž๐๐ ๐†๐‡๐ˆ'.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 32') :-
\+ pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐ƒ๐„๐…', '๐Ž๐๐', _, [boundary(word)]).
/* setting boundary=part, ignore_case=true */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 33') :-
pattern_replace(foobarbaz, 'BAR', tok, X, [boundary(part), ignore_case(true)]),
X == fooTOKbaz.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 34') :-
\+ pattern_replace(foobarbaz, 'FOOBAZ', tok, _, [boundary(part), ignore_case(true)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 35') :-
pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', ๐ซ๐ฌ๐ญ, '๐Ž๐๐', X, [boundary(part), ignore_case(true)]),
X == '๐€๐๐‚๐ถ๐ท๐ธ๐†๐‡๐ˆ'.
/* setting boundary=word, ignore_case=true */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 36') :-
pattern_replace('foo bar baz', 'BAR', tok, X, [boundary(word), ignore_case(true)]),
X == 'foo TOK baz'.
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 37') :-
\+ pattern_replace('foo foo bar', baz, tok, _, [boundary(word), ignore_case(true)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(pattern_replace, 4, extra_regex, 'XLOG 2.3.2, XLOG 38') :-
pattern_replace('๐€๐๐‚ ๐ƒ๐„๐… ๐†๐‡๐ˆ', ๐ซ๐ฌ๐ญ, '๐Ž๐๐', X, [boundary(word), ignore_case(true)]),
X == '๐€๐๐‚ ๐ถ๐ท๐ธ ๐†๐‡๐ˆ'.
/* last_pattern_replace(S, P, R, T) */
/* default settings */
runner:ref(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3').
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 1') :-
\+ last_pattern_replace(foobarbaz, bar, tok, _).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 2') :-
\+ last_pattern_replace(foobarbaz, '*bar', '*tok', _).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 3') :-
last_pattern_replace(foobarbaz, '*bar*', '*tok*', X), X == footokbaz.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 4') :-
last_pattern_replace(foobarbaz, '*baz', '*tok', X), X == foobartok.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 5') :-
\+ last_pattern_replace(foobarbaz, foo, tok, _).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 6') :-
\+ last_pattern_replace(foobarbaz, '*foo', '*tok', _).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 7') :-
last_pattern_replace(foobarbaz, 'foo*', 'tok*', X), X == tokbarbaz.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 8') :-
last_pattern_replace(foobarbaz, '*foo*', '*tok*', X), X == tokbarbaz.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 9') :-
last_pattern_replace(foobarfoobar, '*bar*', '*tok*', X),
X == foobarfootok.
/* unicode >0xFFFF, deseret alphabet */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 10') :-
last_pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '*๐ƒ๐„๐…*', '*๐Ž๐๐*', X),
X == '๐€๐๐‚๐Ž๐๐๐†๐‡๐ˆ'.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 11') :-
\+ last_pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐†๐‡๐ˆ*', '๐Ž๐๐*', _).
/* setting ignore_case=true */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 12') :-
\+ last_pattern_replace(foobarbaz, 'BAR*', 'tok*', _, [ignore_case(true)]).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 13') :-
\+ last_pattern_replace('FOOBARBAZ', baz, tok, _, [ignore_case(true)]).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 14') :-
\+ last_pattern_replace(foobarbaz, 'BAZ*', 'tok*', _, [ignore_case(true)]).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 15') :-
last_pattern_replace(foobarbaz, '*BAZ*', '*TOK*', X, [ignore_case(true)]),
X == foobartok.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 16') :-
last_pattern_replace('FOOBARFOOBAR', '*foo*', '*tok*', X, [ignore_case(true)]),
X == 'FOOBARTOKBAR'.
/* unicode >0xFFFF, deseret alphabet */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 17') :-
last_pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '*๐ซ๐ฌ๐ญ*', '*๐Ž๐๐*', X, [ignore_case(true)]),
X == '๐€๐๐‚๐ถ๐ท๐ธ๐†๐‡๐ˆ'.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 18') :-
\+ last_pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐ฎ๐ฏ๐ฐ*', '๐Ž๐๐*', _, [ignore_case(true)]).
/* setting boundary=part */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 19') :-
\+ last_pattern_replace(foobarbaz, tak, tok, _, [boundary(part)]).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 20') :-
last_pattern_replace(foobarbaz, bar, tok, X, [boundary(part)]),
X == footokbaz.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 21') :-
last_pattern_replace(foobarbaz, foo, tok, X, [boundary(part)]),
X == tokbarbaz.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 22') :-
last_pattern_replace(foobarbaz, baz, tok, X, [boundary(part)]),
X == foobartok.
/* unicode >0xFFFF, deseret alphabet */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 23') :-
last_pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐ƒ๐„๐…', '๐Ž๐๐', X, [boundary(part)]),
X == '๐€๐๐‚๐Ž๐๐๐†๐‡๐ˆ'.
/* setting boundary=word */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 24') :-
\+ last_pattern_replace('foo bar baz', tak, tok, _, [boundary(word)]).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 25') :-
last_pattern_replace('foo bar baz', bar, tok, X, [boundary(word)]),
X == 'foo tok baz'.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 26') :-
\+ last_pattern_replace('foo barbaz', bar, tok, _, [boundary(word)]).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 27') :-
last_pattern_replace('foo bar baz', foo, tok, X, [boundary(word)]),
X == 'tok bar baz'.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 28') :-
\+ last_pattern_replace('foobar baz', foo, tok, _, [boundary(word)]).
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 29') :-
last_pattern_replace('foo bar baz', baz, tok, X, [boundary(word)]),
X == 'foo bar tok'.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 30') :-
\+ last_pattern_replace('foo barbaz', baz, tok, _, [boundary(word)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 31') :-
last_pattern_replace('๐€๐๐‚ ๐ƒ๐„๐… ๐†๐‡๐ˆ', '๐ƒ๐„๐…', '๐Ž๐๐', X, [boundary(word)]),
X == '๐€๐๐‚ ๐Ž๐๐ ๐†๐‡๐ˆ'.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 32') :-
\+ last_pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', '๐ƒ๐„๐…', '๐Ž๐๐', _, [boundary(word)]).
/* setting boundary=part, ignore_case=true */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 33') :-
last_pattern_replace(foobarbaz, 'BAR', tok, X, [boundary(part), ignore_case(true)]),
X == fooTOKbaz.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 34') :-
\+ last_pattern_replace(foobarbaz, 'FOOBAZ', tok, _, [boundary(part), ignore_case(true)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 35') :-
last_pattern_replace('๐€๐๐‚๐ƒ๐„๐…๐†๐‡๐ˆ', ๐ซ๐ฌ๐ญ, '๐Ž๐๐', X, [boundary(part), ignore_case(true)]),
X == '๐€๐๐‚๐ถ๐ท๐ธ๐†๐‡๐ˆ'.
/* setting boundary=word, ignore_case=true */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 36') :-
last_pattern_replace('foo bar baz', 'BAR', tok, X, [boundary(word), ignore_case(true)]),
X == 'foo TOK baz'.
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 37') :-
\+ last_pattern_replace('foo foo bar', baz, tok, _, [boundary(word), ignore_case(true)]).
/* unicode >0xFFFF, deseret alphabet */
runner:case(last_pattern_replace, 4, extra_regex, 'XLOG 2.3.3, XLOG 38') :-
last_pattern_replace('๐€๐๐‚ ๐ƒ๐„๐… ๐†๐‡๐ˆ', ๐ซ๐ฌ๐ญ, '๐Ž๐๐', X, [boundary(word), ignore_case(true)]),
X == '๐€๐๐‚ ๐ถ๐ท๐ธ ๐†๐‡๐ˆ'.
/*******************************************************************/
/* Parse Patern Match etc.. Ignore Case */
/*******************************************************************/
/* pattern_match(S, P, O) */
runner:ref(pattern_match, 3, extra_regex, 'XLOG 2.4.1').
runner:case(pattern_match, 3, extra_regex, 'XLOG 2.4.1, XLOG 1') :-
pattern_match(foobarbaz, '*bar*', [style(parse)]).
/* ignore_case=true downgrade */
runner:case(pattern_match, 3, extra_regex, 'XLOG 2.4.1, XLOG 2') :-
pattern_match(foobarbaz, '*BAR*', [ignore_case(true), style(parse)]).
runner:case(pattern_match, 3, extra_regex, 'XLOG 2.4.1, XLOG 3') :-
\+ pattern_match(foobarbaz, '=*BAR*', [ignore_case(true), style(parse)]).
/* bondary=part downgrade */
runner:case(pattern_match, 3, extra_regex, 'XLOG 2.4.1, XLOG 3') :-
pattern_match(foobarbaz, bar, [boundary(part), style(parse)]).
runner:case(pattern_match, 3, extra_regex, 'XLOG 2.4.1, XLOG 4') :-
\+ pattern_match(foobarbaz, '`bar`', [boundary(part), style(parse)]).
/* pattern_replace(S, P, R, T, O) */
runner:ref(pattern_replace, 5, extra_regex, 'XLOG 2.4.2').
runner:case(pattern_replace, 5, extra_regex, 'XLOG 2.4.2, XLOG 1') :-
pattern_replace(foobarfoobar, '*bar*', '*tok*', X, [style(parse)]),
X == footokfoobar.
/* ignore_case=true downgrade */
runner:case(pattern_replace, 5, extra_regex, 'XLOG 2.4.2, XLOG 2') :-
pattern_replace(foobarfoobar, '*BAR*', '*tok*', X, [ignore_case(true), style(parse)]),
X == fooTOKfoobar.
runner:case(pattern_replace, 5, extra_regex, 'XLOG 2.4.2, XLOG 3') :-
\+ pattern_replace(foobarfoobar, '=*BAR*', '*tok*', _, [ignore_case(true), style(parse)]).
/* bondary=part downgrade */
runner:case(pattern_replace, 5, extra_regex, 'XLOG 2.4.2, XLOG 4') :-
pattern_replace(foobarfoobar, bar, tok, X, [boundary(part), style(parse)]),
X == footokfoobar.
runner:case(pattern_replace, 5, extra_regex, 'XLOG 2.4.2, XLOG 5') :-
\+ pattern_replace(foobarfoobar, '`bar`', '`tok`', _, [boundary(part), style(parse)]).
/* last_pattern_replace(S, P, R, T, O) */
runner:ref(last_pattern_replace, 5, extra_regex, 'XLOG 2.4.3').
runner:case(last_pattern_replace, 5, extra_regex, 'XLOG 2.4.3, XLOG 1') :-
last_pattern_replace(foobarfoobar, '*bar*', '*tok*', X, [style(parse)]),
X == foobarfootok.
/* ignore_case=true downgrade */
runner:case(last_pattern_replace, 5, extra_regex, 'XLOG 2.4.3, XLOG 2') :-
last_pattern_replace(foobarfoobar, '*BAR*', '*tok*', X, [ignore_case(true), style(parse)]),
X == foobarfooTOK.
runner:case(last_pattern_replace, 5, extra_regex, 'XLOG 2.4.3, XLOG 3') :-
\+ last_pattern_replace(foobarfoobar, '=*BAR*', '*tok*', _, [ignore_case(true), style(parse)]).
/* bondary=part downgrade */
runner:case(last_pattern_replace, 5, extra_regex, 'XLOG 2.4.3, XLOG 4') :-
last_pattern_replace(foobarfoobar, bar, tok, X, [boundary(part), style(parse)]),
X == foobarfootok.
runner:case(last_pattern_replace, 5, extra_regex, 'XLOG 2.4.3, XLOG 5') :-
\+ last_pattern_replace(foobarfoobar, '`bar`', '`tok`', _, [boundary(part), style(parse)]).

Kommentare