diff options
Diffstat (limited to 'Master/texmf-dist/doc/lualatex/lualatex-math/test-unicode.tex')
-rw-r--r-- | Master/texmf-dist/doc/lualatex/lualatex-math/test-unicode.tex | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/lualatex/lualatex-math/test-unicode.tex b/Master/texmf-dist/doc/lualatex/lualatex-math/test-unicode.tex index 1551142aaa3..ef17d68cc05 100644 --- a/Master/texmf-dist/doc/lualatex/lualatex-math/test-unicode.tex +++ b/Master/texmf-dist/doc/lualatex/lualatex-math/test-unicode.tex @@ -22,7 +22,9 @@ %% \documentclass[pagesize=auto]{scrartcl} \usepackage{xparse}[2008/08/03] +\usepackage{luacode} \ExplSyntaxOn +\AtBeginDocument { \errorcontextlines = \c_fifteen } \msg_new:nnn { test } { pass } { #1 } \cs_new_protected_nopar:Npn \test_pass:x #1 { \msg_info:nnx { test } { pass } { #1 } @@ -115,6 +117,82 @@ \NewDocumentCommand \AssertCrampedStyle { } { \test_assert_cramped:Nx \int_if_odd_p:n { cramped } } +\box_new:N \l_test_tmpa_box +\box_new:N \l_test_tmpb_box +\begin{luacode*} +function contains_space(head, width) + for n in node.traverse(head) do + local id = n.id + if id == 10 or id == 11 then + if width then + if (id == 10 and n.spec.width == width) + or (id == 11 and n.kern == width) then + return true + end + else + return true + end + elseif id == 0 or id == 1 then + if contains_space(n.head, width) then + return true + end + end + end + return false +end +\end{luacode*} +\NewDocumentCommand \AssertNoSpace { m } { + \hbox_set:Nn \l_test_tmpa_box { #1 } + \int_if_odd:nTF { + \lua_now:x { + local~ b = tex.getbox(\int_use:N \l_test_tmpa_box) + if~ contains_space(b.head) then~ + tex.sprint("0") + else~ + tex.sprint("1") + end + } + } { + \test_pass:x { + \tl_to_str:n { #1 } ~ + contains~ no~ skip~ or~ kern~ node + } + } { + \test_fail:x { + \tl_to_str:n { #1 } ~ + contains~ a~ skip~ or~ kern~ node + } + } +} +\makeatletter +\NewDocumentCommand \AssertMuSpace { m m } { + \hbox_set:Nn \l_test_tmpa_box { #1 } + \hbox_set:Nn \l_test_tmpb_box { $ \mskip #2 \m@th $ } + \int_if_odd:nTF { + \lua_now:x { + local~ b = tex.getbox(\int_use:N \l_test_tmpa_box) + local~ s = tex.getbox(\int_use:N \l_test_tmpb_box) + if~ contains_space(b.head, s.width) then~ + tex.sprint("1") + else~ + tex.sprint("0") + end + } + } { + \test_pass:x { + \tl_to_str:n { #1 } ~ + contains~ a~ skip~ or~ kern~ node~ of~ width~ + \tl_to_str:n { #2 } + } + } { + \test_fail:x { + \tl_to_str:n { #1 } ~ + contains~ no~ skip~ or~ kern~ node~ of~ width~ + \tl_to_str:n { #2 } + } + } +} +\makeatother \ExplSyntaxOff \ExplSyntaxOn \msg_redirect_class:nn { warning } { error } |