Debian Codegraph @

texmf-dist/doc/xelatex/interchar/interchartest.tex

raw
1 % -*- coding: utf-8 -*-
2 \documentclass{article}
3
4 \usepackage[b5paper]{geometry}
5 \usepackage{pifont,xcolor,etoolbox}
6 %\usepackage[check-declarations,log-functions]{expl3}
7 \usepackage{expl3,xparse}
8 \ExplSyntaxOn
9 \newcommand{\patchsuccess}[1]{\typeout{Patching~of~\string#1~succeeded.}}
10 \newcommand{\patchfailure}[1]{\typeout{Patching~of~\string#1~failed!}}
11 \ifx \chk_if_free_cs:N \undefined
12 \apptocmd{\__chk_if_free_cs:N}
13 { \iow_log:x { Defining\c_space_tl\token_to_str:N #1\c_space_tl\msg_line_context: } }
14 { \patchsuccess{\__chk_if_free_cs:N}} { \patchfailure{\__chk_if_free_cs:N} }
15 \else
16 \apptocmd{\chk_if_free_cs:N}
17 { \iow_log:x { Defining\c_space_tl\token_to_str:N #1\c_space_tl\msg_line_context: } }
18 { \patchsuccess{\chk_if_free_cs:N}} { \patchfailure{\chk_if_free_cs:N} }
19 \fi
20 %\show\chk_if_free_cs:N
21 \ExplSyntaxOff
22 \usepackage{interchar}
23
24 \setlength{\parskip}{2pt plus 1pt}
25 \setlength{\parindent}{0pt}
26 \pagestyle{empty}
27 \newcommand{\unspace}{\unskip\unskip\unskip\unskip\unskip\unskip}
28 \newcommand{\passed}{\unspace\hspace{6pt}\textcolor{teal}{\ding{51}}}
29 \newcommand{\failed}{\unspace\hspace{6pt}\textcolor{purple}{\ding{55}}}
30
31 \begin{document}
32
33 %\ExplSyntaxOn
34 %\char_set_catcode_space:n {`\ }
35 \catcode `\_ = 11 \catcode `\: = 11
36
37 \cs_generate_variant:Nn \tl_if_eq:nnTF {V,x}
38
39 Testing \verb-\__interchar_class_compare_char:nn-
40 \cs_new_eq:NN \comparechar \__interchar_class_compare_char:nn
41 \tl_set:Nx\l_tmpa_tl{\comparechar{2}{A},\comparechar{10}{A},\comparechar{12}{A}.%
42 \comparechar{40}{2A-2F},\comparechar{45}{2A-2F},\comparechar{50}{2A-2F}.}
43 \tl_if_eq:xnTF {\tl_to_str:N \l_tmpa_tl} {-1,0,1.-1,0,1.} {\passed}{\failed}
44
45 Testing \verb-\__interchar_class_split_range:nNN-
46 \__interchar_class_split_range:nNN {1234-ABCD} \l_tmpa_tl \l_tmpb_tl
47 \tl_if_eq:VnTF \l_tmpb_tl {ABCD} {\passed}{\failed}
48 \__interchar_class_split_range:nNN {ABCD} \l_tmpa_tl \l_tmpb_tl
49 \tl_if_eq:NNTF \l_tmpa_tl \l_tmpb_tl {\passed}{\failed}
50 \__interchar_class_split_range:nNN {"AC-"BD} \l_tmpa_tl \l_tmpb_tl
51 \tl_if_eq:VnTF \l_tmpb_tl {"BD} {\passed}{\failed}
52 \__interchar_class_split_range:nNN {"AC} \l_tmpa_tl \l_tmpb_tl
53 \tl_if_eq:NNTF \l_tmpa_tl \l_tmpb_tl {\passed}{\failed}
54 \__interchar_class_split_range:nNN {`\A} \l_tmpa_tl \l_tmpb_tl
55 \tl_if_eq:VnTF \l_tmpb_tl {`\A} {\passed}{\failed}
56
57 The quick brown fox jumps over the lazy dog.
58 The quick brown fox jumps over the lazy dog.
59 The quick brown fox jumps over the lazy dog.
60
61 \vspace{1em}
62
63 Testing \verb-\newintercharscheme{foo}-
64 \newintercharscheme{foo}
65 \cs_if_exist:cTF {l_interchar_foo_chars_3_clist} {\passed}{\failed}
66
67 Testing \verb-\newintercharclass[foo]{#2}-
68 \newintercharclass[foo]{\myclassU}
69 \newintercharclass[foo]{\myclassV}
70 \clist_if_in:NnTF \g_interchar_foo_classes_clist {4} {\passed}{\failed}
71
72 %\intercharclass{"1234}{1}
73 %\intercharclass{"FF45}{2}
74 %\intercharclass{"4567}{3}
75
76 % `\A `\F `\K `\P `\U `\Z `\a `\f `\k `\p `\u `\z
77 % "41 "46 "4B "50 "55 "5A "61 "66 "6B "70 "75 "7A
78 % 65 70 75 80 85 90 97 102 107 112 117 122
79 % '101 '106 '113 '120 '125 '132 '141 '146 '153 '160 '165 '172
80 Testing \verb-\intercharclass[foo]{#2}{#3}-
81 \intercharclass[foo]{"4B}{9}
82 \cs_if_exist:cTF {l_interchar_foo_chars_9_clist} {\passed}{\failed}
83 \intercharclass[foo]{"4B}{0}
84 \clist_if_empty:cTF {l_interchar_foo_chars_9_clist} {\passed}{\failed}
85 \intercharclass[foo]{"5A}{1}
86 \intercharclass[foo]{"5A}{2}
87 \clist_if_in:cnTF {l_interchar_foo_chars_2_clist} {5A} {\passed}{\failed}
88 \intercharclass[foo]{"5A}{3}
89 \clist_if_empty:cTF {l_interchar_foo_chars_2_clist} {\passed}{\failed}
90 \intercharclass[foo]{"44-"47}{3}
91 \clist_if_in:cnTF {l_interchar_foo_chars_3_clist} {44-47} {\passed}{\failed}
92 \intercharclass[foo]{"50-"53}{3}
93 \clist_if_in:cnTF {l_interchar_foo_chars_3_clist} {50-53} {\passed}{\failed}
94 \intercharclass[foo]{"48-"51}{2}
95 \clist_if_in:cnTF {l_interchar_foo_chars_3_clist} {52-53} {\passed}{\failed}
96 \intercharclass[foo]{"45}{2}
97 \clist_if_in:cnTF {l_interchar_foo_chars_3_clist} {46-47} {\passed}{\failed}
98
99 Testing \verb-\getintercharclass[foo]{#2}{#3}-
100 \cs_new_eq:NN \getclass \interchar_get_class:nn
101 \tl_set:Nx \l_tmpa_tl {\getclass{default}{"5555}\getclass{default}{"300A}\getclass{default}{"3001}}
102 \tl_if_eq:xnTF {\tl_to_str:N \l_tmpa_tl} {123} {\passed}{\failed}
103 \getintercharclass{"3456}{\l_tmpa_tl}
104 \tl_if_eq:VnTF \l_tmpa_tl {1} {\passed}{\failed}
105
106 Testing \verb-\interchartoks[foo]{#2}{#3}{#4}-
107 \newintercharclass[foo]{\myclassW}
108 \intercharclass[foo]{`\o}{\myclassW}
109 \interchartoks[foo]{0}{\myclassW}{\bgroup\color{blue}}
110 \interchartoks[foo]{255}{\myclassW}{\bgroup\color{blue}}
111 \interchartoks[foo]{\myclassW}{0}{\egroup}
112 \interchartoks[foo]{\myclassW}{255}{\egroup}
113 \prop_get:NnN \l_interchar_foo_toks_prop {255 6} \l_tmpa_tl
114 \tl_if_eq:VnTF \l_tmpa_tl {\bgroup\color{blue}} {\passed}{\failed}
115
116 \XeTeXinterchartokenstate = 0
117 Testing \verb-\getinterchartoks[foo]{#2}{#3}{#4}-
118 \interchartoks[foo]{\myclassW}{1}{u}
119 \tl_set:Nx \l_tmpa_tl {\interchar_get_toks:nVn{foo}{\myclassW}{1}}
120 \tl_if_eq:VnTF \l_tmpa_tl {u} {\passed}{\failed}
121
122 \XeTeXinterchartokenstate = 0
123 Testing \verb-\intercharstate[foo]{#2}-:
124 \intercharstate[foo]{0}
125 \tl_if_eq:VnTF {\XeTeXcharclass `\o} {0} {\passed}{\failed}
126 \tl_if_eq:VnTF {\XeTeXinterchartoks 0 1} {\xtxHanSpace} {\passed}{\failed}
127
128 \XeTeXinterchartokenstate = 1
129 Testing \verb-\getintercharstate[foo]{#2}-:
130 \getintercharstate[foo]{\l_tmpa_tl}
131 \tl_if_eq:VnTF \l_tmpa_tl {0} {\passed}{\failed}
132 \intercharstate[foo]{2}
133 \tl_set:Nx \l_tmpa_tl {\interchar_get_state:n{foo}}
134 \tl_if_eq:xnTF {\tl_to_str:N \l_tmpa_tl} {1} {\passed}{\failed}
135
136 The quick brown fox jumps over the lazy dog.
137 The quick brown fox jumps over the lazy dog.
138 The quick brown fox jumps over the lazy dog.
139
140 \vspace{1em}
141
142 \XeTeXinterchartokenstate = 0
143 Testing \verb-\NewFooIntercharClass #1-
144 \NewFooIntercharClass \myclassQ
145 \clist_if_in:NnTF \g_interchar_foo_classes_clist {7} {\passed}{\failed}
146
147 Testing \verb-\FooIntercharClass #1 = #2-
148 \FooIntercharClass `\c = \myclassU
149 \FooIntercharClass `\b = \myclassU
150 \FooIntercharClass `\a = \myclassU
151 \clist_if_in:cnTF {l_interchar_foo_chars_4_clist} {61-63} {\passed}{\failed}
152 \FooIntercharClass `\y \myclassV
153 \FooIntercharClass `\z \myclassV
154 \clist_if_in:cnTF {l_interchar_foo_chars_5_clist} {79-7A} {\passed}{\failed}
155 \FooIntercharClass "43 9
156 \FooIntercharClass "45 9
157 \FooIntercharClass "44 9
158 \clist_if_in:cnTF {l_interchar_foo_chars_9_clist} {43-45} {\passed}{\failed}
159 \FooIntercharClass `\L 9
160 \FooIntercharClass `\M 9
161 \FooIntercharClass `\O 9
162 \FooIntercharClass `\N 9
163 \clist_if_in:cnTF {l_interchar_foo_chars_9_clist} {4C-4F} {\passed}{\failed}
164 \FooIntercharClass `\N 0
165 \clist_if_in:cnTF {l_interchar_foo_chars_9_clist} {4C-4D} {\passed}{\failed}
166 \FooIntercharClass `\L 0
167 \FooIntercharClass `\M 0
168 \FooIntercharClass `\N 0
169 \FooIntercharClass `\O 0
170 \FooIntercharClass `\E 0
171 \FooIntercharClass `\C 0
172 \FooIntercharClass `\D 0
173 \clist_if_empty:cTF {l_interchar_foo_chars_9_clist} {\passed}{\failed}
174
175 Testing \verb-\FooIntercharToks #1 #2 = {#3}-
176 \FooIntercharToks \myclassU \myclassV = {\textcolor{red}{zzz}}
177 \prop_get:NnN \l_interchar_foo_toks_prop {4 5} \l_tmpa_tl
178 \tl_if_eq:VnTF \l_tmpa_tl {\textcolor{red}{zzz}} {\passed}{\failed}
179
180 Testing \verb-\FooIntercharState = #1-
181 \FooIntercharClass `\o = \myclassV
182 \FooIntercharState = 1
183 %aa\the\XeTeXinterchartoks 4 5 bb
184 \tl_if_eq:VnTF {\XeTeXcharclass `\o} {5} {\passed}{\failed}
185 \tl_if_eq:VnTF {\XeTeXinterchartoks 4 5} {\textcolor{red}{zzz}} {\passed}{\failed}
186
187 \FooIntercharState = 2
188 Testing \verb-\GetFooIntercharState-:
189 \ifnum \GetFooIntercharState = 1 \passed \else \failed \fi
190
191 \XeTeXinterchartokenstate = 0
192 Testing \verb-\BarIntercharState = #1-:
193 \XeTeXinterchartokenstate = 1
194 \newintercharscheme{bar}
195 \NewBarIntercharClass \myclassX
196 \BarIntercharClass `\f \myclassX
197 \BarIntercharClass `\x \myclassX
198 \NewBarIntercharClass \myclassY
199 \BarIntercharClass `\d \myclassY
200 \BarIntercharClass `\g \myclassY
201 \BarIntercharClass `\. \myclassY
202 \BarIntercharToks 255 \myclassX = {\bgroup\color{orange}}
203 \BarIntercharToks \myclassX 255 = {\egroup}
204 \BarIntercharToks 255 \myclassY = {\bgroup\color{olive}}
205 \BarIntercharToks \myclassY 255 = {\egroup}
206 \tl_if_eq:xnTF \l_interchar_current_scheme_tl {foo} {\passed}{\failed}
207 \BarIntercharState = 1
208 \tl_if_eq:VnTF \l_interchar_current_scheme_tl {bar} {\passed}{\failed}
209 \tl_if_eq:VnTF {\XeTeXcharclass `\d} {5} {\passed}{\failed}
210 \tl_if_eq:VnTF {\XeTeXinterchartoks 255 4} {\bgroup\color{orange}} {\passed}{\failed}
211
212 The quick brown fox jumps over the lazy dog.
213 The quick brown fox jumps over the lazy dog.
214 The quick brown fox jumps over the lazy dog.
215
216 \BarIntercharState = 1
217
218 \FooIntercharState = 1
219
220 The quick brown fox jumps over the lazy dog.
221 The quick brown fox jumps over the lazy dog.
222 The quick brown fox jumps over the lazy dog.
223
224 % ------------------------------------------------------------------------------
225
226 %\clist_show:c {l_interchar_default_chars_1_clist}
227 %\clist_show:c {l_interchar_default_chars_2_clist}
228 %\clist_show:c {l_interchar_default_chars_3_clist}
229 %\clist_show:c {l_interchar_foo_chars_4_clist}
230 %\clist_show:c {l_interchar_foo_chars_5_clist}
231 %\prop_show:N \l_interchar_foo_toks_prop
232 %\prop_show:N \l_interchar_bar_toks_prop
233
234 \catcode `\_ = 8 \catcode `\: = 12
235 %\char_set_catcode_ignore:n {`\ }%
236 %\ExplSyntaxOff
237
238 \end{document}