diff options
author | Karl Berry <karl@freefriends.org> | 2011-09-14 22:20:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-09-14 22:20:59 +0000 |
commit | 212490225178a301cd0756b00c5f85d64952e409 (patch) | |
tree | 7754d0177d5c780b19e8eee8a3b03a02b2c50f6f /Master/texmf-dist/doc/lualatex/lualatex-math/test-icomma.tex | |
parent | 5555ff2ea4569008e29412e2e5eac0b264483855 (diff) |
lualatex-math post-0.1 (14sep11)
git-svn-id: svn://tug.org/texlive/trunk@23953 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/lualatex/lualatex-math/test-icomma.tex')
-rw-r--r-- | Master/texmf-dist/doc/lualatex/lualatex-math/test-icomma.tex | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/lualatex/lualatex-math/test-icomma.tex b/Master/texmf-dist/doc/lualatex/lualatex-math/test-icomma.tex new file mode 100644 index 00000000000..037b05cb4a4 --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/lualatex-math/test-icomma.tex @@ -0,0 +1,207 @@ +%% +%% This is file `test-icomma.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% lualatex-math.dtx (with options: `test,test-icomma') +%% +%% This is a generated file. +%% +%% Copyright 2011 by Philipp Stephani +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3c of this license or (at your option) any later +%% version. The latest version of this license is in +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3c or later is part of all distributions of +%% LaTeX version 2009/09/24 or later. +%% +\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 } +} +\msg_new:nnn { test } { fail } { #1 } +\cs_new_protected_nopar:Npn \test_fail:x #1 { + \msg_error:nnx { test } { fail } { #1 } +} +\cs_generate_variant:Nn \tl_const:Nn { Nx } +\tl_const:Nx \c_test_equal_tl { \c_space_tl == \c_space_tl } +\tl_const:Nx \c_test_not_equal_tl { \c_space_tl != \c_space_tl } +\cs_new_protected_nopar:Npn \test_equal_pass:nxnx #1 #2 #3 #4 { + \test_pass:x { + \exp_not:n { #1 } + \c_test_equal_tl + #2 + \c_test_equal_tl + #4 + \c_test_equal_tl + \exp_not:n { #3 } + } +} +\cs_new_protected_nopar:Npn \test_equal_fail:nxnx #1 #2 #3 #4 { + \test_fail:x { + \exp_not:n { #1 } + \c_test_equal_tl + #2 + \c_test_not_equal_tl + #4 + \c_test_equal_tl + \exp_not:n { #3 } + } +} +\cs_new_protected_nopar:Npn +\test_assert_equal:NNNNNnn #1 #2 #3 #4 #5 #6 #7 { + #1 #4 { #6 } + #1 #5 { #7 } + #3 { #4 } = { #5 } { + \test_equal_pass:nxnx { #6 } { #2 #4 } { #7 } { #2 #5 } + } { + \test_equal_fail:nxnx { #6 } { #2 #4 } { #7 } { #2 #5 } + } +} +\cs_generate_variant:Nn \test_assert_equal:NNNNNnn { ccccc } +\cs_new_protected_nopar:Npn \test_assert_equal:nnn #1 #2 #3 { + \test_assert_equal:cccccnn + { #1 _set:Nn } { #1 _use:N } { #1 _compare:nNnTF } + { l_test_tmpa_ #1 } { l_test_tmpb_ #1 } { #2 } { #3 } +} +\int_new:N \l_test_tmpa_int +\int_new:N \l_test_tmpb_int +\NewDocumentCommand \AssertIntEqual { m m } { + \test_assert_equal:nnn { int } { #1 } { #2 } +} +\dim_new:N \l_test_tmpa_dim +\dim_new:N \l_test_tmpb_dim +\NewDocumentCommand \AssertDimEqual { m m } { + \test_assert_equal:nnn { dim } { #1 } { #2 } +} +\NewDocumentCommand \AssertMathStyle { m } { + \AssertIntEqual { \luatexmathstyle } { #1 } +} +\cs_new_protected_nopar:Npn \test_assert_cramped:Nx #1 #2 { + \int_set:Nn \l_test_tmpa_int { \luatexmathstyle } + \bool_if:nTF { + \int_compare_p:nNn { \l_test_tmpa_int } > { \c_minus_one } + && + #1 { \l_test_tmpa_int } + } { + \test_pass:x { + \exp_not:N \luatexmathstyle + \c_test_equal_tl + \int_use:N \l_test_tmpa_int + \c_space_tl + is~ a~ #2~ style + } + } { + \test_fail:x { + \exp_not:N \luatexmathstyle + \c_test_equal_tl + \int_use:N \l_test_tmpa_int + \c_space_tl + is~ not~ a~ #2~ style + } + } +} +\NewDocumentCommand \AssertNoncrampedStyle { } { + \test_assert_cramped:Nx \int_if_even_p:n { non-cramped } +} +\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 +\usepackage{lualatex-math} +\usepackage{icomma} +\begin{document} +$1,234 \; (x, y)$ +\AssertNoSpace{$1,234$} +\AssertMuSpace{$(x, y)$}{\thinmuskip} +\AssertIntEqual{\mathcomma}{"1C0003B} +\end{document} +\endinput +%% +%% End of file `test-icomma.tex'. |